diff --git a/bucket_of_utils/pdf/add_title_to_first_page.html b/bucket_of_utils/pdf/add_title_to_first_page.html index df37c06..285942b 100644 --- a/bucket_of_utils/pdf/add_title_to_first_page.html +++ b/bucket_of_utils/pdf/add_title_to_first_page.html @@ -11,7 +11,7 @@ - packages = ["pdf-annotate"] + packages = ["pdf-annotate", "unidecode"] [[fetch]] files = ["./add_title_to_first_page.py"] @@ -28,7 +28,7 @@

Config

Files

- +

Process

diff --git a/bucket_of_utils/pdf/index.py b/bucket_of_utils/pdf/index.py index 8f13c0b..84f06db 100644 --- a/bucket_of_utils/pdf/index.py +++ b/bucket_of_utils/pdf/index.py @@ -13,6 +13,7 @@ from js import window from pyodide.ffi import create_proxy from pyodide.ffi import to_js +from unidecode import unidecode CONFIG_DISABLED = True @@ -90,7 +91,9 @@ async def _process_files(*_, **__): reader = pdfrw.PdfReader(stream) doc = pdf_annotate.PdfAnnotator(reader) - converted = add_file_name_annotation_to_pdf(doc=doc, file_name=file_.name) + file_name = unidecode(file_.name) + + converted = add_file_name_annotation_to_pdf(doc=doc, file_name=file_name) with tempfile.NamedTemporaryFile() as f: converted.write(f) f.seek(0) diff --git a/pyproject.toml b/pyproject.toml index 9f4e8e5..88c9a4b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,6 +12,7 @@ dependencies = [ "shellingham>=1.5.0.post1", "pyodide-py>=0.23.4", "types-requests>=2.31.0.2", + "unidecode>=1.3.6", ] readme = "README.md" requires-python = ">= 3.11" diff --git a/requirements-dev.lock b/requirements-dev.lock index 1ff0dd7..0497f3e 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -47,6 +47,7 @@ typer==0.9.0 types-requests==2.31.0.2 types-urllib3==1.26.25.14 typing-extensions==4.7.1 +unidecode==1.3.6 urllib3==2.0.4 virtualenv==20.24.2 # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements.lock b/requirements.lock index 4b517b1..06aba0d 100644 --- a/requirements.lock +++ b/requirements.lock @@ -28,4 +28,5 @@ typer==0.9.0 types-requests==2.31.0.2 types-urllib3==1.26.25.14 typing-extensions==4.7.1 +unidecode==1.3.6 urllib3==2.0.4