Open dasmy opened 4 days ago
Using doc.embfile_add(), I added an attachment to a pdf file. Then, I retrieved its metadata using doc.embfile_info().
doc.embfile_add()
doc.embfile_info()
In contrast to the documentation at https://pymupdf.readthedocs.io/en/latest/document.html#Document.embfile_info, the resulting dict does not contain a desc field for the description. Instead, the description is found under the key descender:
desc
descender
print(doc.embfile_info(name)) {'name': 'pdf_scraper_markdown_content', 'collection': 0, 'filename': 'fulltext.md', 'ufilename': 'fulltext.md', 'descender': 'Markdown representation of the PDF file content.', 'size': 67, 'length': 67, 'creationDate': "D:20241114103806+02'00'", 'modDate': "D:20241114103806+02'00'"}
With docbeing a pymupdf.Document, just call
doc
pymupdf.Document
doc.embfile_add('test', b'foobar', desc='some text') print(doc.embfile_info('test'))
Result:
{'name': 'test', 'collection': 0, 'filename': 'test', 'ufilename': 'test', '**descender**': 'some text', 'size': 6, 'length': 6, 'creationDate': "D:20241114105413+02'00'", 'modDate': "D:20241114105413+02'00'"}
1.24.13
MacOS
3.12
The problem was overwriting a dictionary key value. Easy fix. Of course, "description" is correct, which will be reflected in the returned dictionary and the documentation likewise.
Nice. That was quick 😀
Description of the bug
Using
doc.embfile_add()
, I added an attachment to a pdf file. Then, I retrieved its metadata usingdoc.embfile_info()
.In contrast to the documentation at https://pymupdf.readthedocs.io/en/latest/document.html#Document.embfile_info, the resulting dict does not contain a
desc
field for the description. Instead, the description is found under the keydescender
:How to reproduce the bug
With
doc
being apymupdf.Document
, just callResult:
PyMuPDF version
1.24.13
Operating system
MacOS
Python version
3.12