diff --git a/com.jeffser.Alpaca.json b/com.jeffser.Alpaca.json
index 585d523..8debad1 100644
--- a/com.jeffser.Alpaca.json
+++ b/com.jeffser.Alpaca.json
@@ -85,6 +85,35 @@
}
]
},
+ {
+ "name": "python3-docx2python",
+ "buildsystem": "simple",
+ "build-commands": [
+ "pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"docx2python\" --no-build-isolation"
+ ],
+ "sources": [
+ {
+ "type": "file",
+ "url": "https://files.pythonhosted.org/packages/2a/13/9b36c57b9f0b8c1c7b200f7a715c6ccd64de5b4222283032eaf74efc3111/docx2python-2.10.1-py3-none-any.whl",
+ "sha256": "2a140da0224dbcfe20324b67d59bd235b84c9ea03788e128f98c0a96c4ee9d8e"
+ },
+ {
+ "type": "file",
+ "url": "https://files.pythonhosted.org/packages/63/f7/ffbb6d2eb67b80a45b8a0834baa5557a14a5ffce0979439e7cd7f0c4055b/lxml-5.2.2.tar.gz",
+ "sha256": "bb2dc4898180bea79863d5487e5f9c7c34297414bad54bcd0f0852aee9cfdb87"
+ },
+ {
+ "type": "file",
+ "url": "https://files.pythonhosted.org/packages/a0/e2/a2e5dffdfe89ea328bd04f1411dc6df2f44560fff1335d4f2b8acaa57ea8/paragraphs-0.2.1-py3-none-any.whl",
+ "sha256": "c28dc3cb72c9028871ab22ce57c42f2e3e1a0403332d87abd238c77427e07582"
+ },
+ {
+ "type": "file",
+ "url": "https://files.pythonhosted.org/packages/26/9f/ad63fc0248c5379346306f8668cda6e2e2e9c95e01216d2b8ffd9ff037d0/typing_extensions-4.12.2-py3-none-any.whl",
+ "sha256": "04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d"
+ }
+ ]
+ },
{
"name": "python3-pytube",
"buildsystem": "simple",
diff --git a/src/window.py b/src/window.py
index 08c3a84..e6f7070 100644
--- a/src/window.py
+++ b/src/window.py
@@ -21,7 +21,8 @@ import gi
gi.require_version('GtkSource', '5')
gi.require_version('GdkPixbuf', '2.0')
from gi.repository import Adw, Gtk, Gdk, GLib, GtkSource, Gio, GdkPixbuf
-import json, requests, threading, os, re, base64, sys, gettext, locale, subprocess, uuid, shutil, tarfile, tempfile #, docx
+import json, requests, threading, os, re, base64, sys, gettext, locale, subprocess, uuid, shutil, tarfile, tempfile
+from docx2python import docx2python
from time import sleep
from io import BytesIO
from PIL import Image
@@ -1247,13 +1248,11 @@ Generate a title following these rules:
for i, page in enumerate(reader.pages):
text += f"\n- Page {i}\n{page.extract_text()}\n"
return text
- #elif file_type == 'docx':
- #document = docx.Document(file_path)
- #if len(document.paragraphs) == 0: return None
- #text = ""
- #for paragraph in document.paragraphs:
- #text += f"{paragraph.text}\n"
- #return text
+ elif file_type == 'docx':
+ text = None
+ with docx2python(file_path) as document:
+ text = document.text
+ return text
def remove_attached_file(self, button):
del self.attachments[button.get_name()]
@@ -1276,7 +1275,7 @@ Generate a title following these rules:
"plain_text": "document-text-symbolic",
"pdf": "document-text-symbolic",
"youtube": "play-symbolic",
- #"docx": "document-text-symbolic"
+ "docx": "document-text-symbolic"
}[file_type]
)
button = Gtk.Button(
diff --git a/src/window.ui b/src/window.ui
index 0f0fc73..6f6a2ee 100644
--- a/src/window.ui
+++ b/src/window.ui
@@ -1019,6 +1019,7 @@
json
xml
pdf
+ docx
png
jpeg
jpg