Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve dictionary key override #4051

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions docs/document.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1551,21 +1551,19 @@ For details on **embedded files** refer to Appendix 3.
:rtype: dict
:returns: a dictionary with the following keys:

* *name* -- (*str*) name under which this entry is stored
* *filename* -- (*str*) filename
* *ufilename* -- (*unicode*) filename
* *desc* -- (*str*) description
* *size* -- (*int*) original file size
* *length* -- (*int*) compressed file length
* *creationDate* -- *(New in v1.18.13)* (*str*) date-time of item creation in PDF format
* *modDate* -- *(New in v1.18.13)* (*str*) date-time of last change in PDF format
* *collection* -- *(New in v1.18.13)* (*int*) :data:`xref` of the associated PDF portfolio item if any, else zero.
* *checksum* -- *(New in v1.18.13)* (*str*) a hashcode of the stored file content as a hexadecimal string. Should be MD5 according to PDF specifications, but be prepared to see other hashing algorithms.
* ``name`` -- (*str*) name under which this entry is stored
* ``filename`` -- (*str*) filename
* ``ufilename`` -- (*unicode*) filename
* ``description`` -- (*str*) description
* ``size`` -- (*int*) original file size
* ``length`` -- (*int*) compressed file length
* ``creationDate`` -- (*str*) date-time of item creation in PDF format
* ``modDate`` -- (*str*) date-time of last change in PDF format
* ``collection`` -- (*int*) :data:`xref` of the associated PDF portfolio item if any, else zero.
* ``checksum`` -- (*str*) a hashcode of the stored file content as a hexadecimal string. Should be MD5 according to PDF specifications, but be prepared to see other hashing algorithms.

.. method:: embfile_names()

* New in v1.14.16

PDF only: Return a list of embedded file names. The sequence of the names equals the physical sequence in the document.

:rtype: list
Expand Down
6 changes: 3 additions & 3 deletions src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ def file_info(self):
size = mupdf.pdf_to_int(o)

res[ dictkey_filename] = JM_EscapeStrFromStr(filename)
res[ dictkey_desc] = JM_UnicodeFromStr(desc)
res[ dictkey_descr] = JM_UnicodeFromStr(desc)
res[ dictkey_length] = length
res[ dictkey_size] = size
return res
Expand Down Expand Up @@ -3255,7 +3255,7 @@ def _embfile_info(self, idx, infodict):
infodict[dictkey_ufilename] = JM_EscapeStrFromStr(name)

name = mupdf.pdf_to_text_string(mupdf.pdf_dict_get(o, PDF_NAME('Desc')))
infodict[dictkey_desc] = JM_UnicodeFromStr(name)
infodict[dictkey_descr] = JM_UnicodeFromStr(name)

len_ = -1
DL = -1
Expand Down Expand Up @@ -13668,7 +13668,7 @@ class EmptyFileError(FileDataError):
dictkey_cs_name = "cs-name"
dictkey_da = "da"
dictkey_dashes = "dashes"
dictkey_desc = "desc"
dictkey_descr = "description"
dictkey_desc = "descender"
dictkey_dir = "dir"
dictkey_effect = "effect"
Expand Down
4 changes: 2 additions & 2 deletions tests/test_annots.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ def test_file_info():
print(f'{file_info=}')
results.append(file_info)
assert results == [
{'filename': 'example.pdf', 'descender': '', 'length': 8416, 'size': 8992},
{'filename': 'photo1.jpeg', 'descender': '', 'length': 10154, 'size': 8012},
{'filename': 'example.pdf', 'description': '', 'length': 8416, 'size': 8992},
{'filename': 'photo1.jpeg', 'description': '', 'length': 10154, 'size': 8012},
]

def test_3131():
Expand Down