Python Forum

Full Version: PDF properties doesn't show created or modified date
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I had a lot of small pdfs, which I merged to 1 big pdf using PyPDF2, a great tool! Works perfectly!

When I open the big pdf, and go to File Options -> Properties I can see most of the info I set, but CREATED and MODIFIED just show None

Do I have to put in the dates in a special format? I was hoping I could just put text!

Here is the meta data:

# Add the metadata
    writer.add_metadata(
        {
            "/Author": "Roy Rodgers",
            "/Producer": "PyPDF2",
            "/Created": "Wednesday May 17 2023",        
            "/Modified": "Regularly",
            "/Date": "Wednesday May 17 2023",
            "/Place": "中国江苏南京市",
            "/Title": "An Alternative",
            "/Pages": "287",
            "/Words": "101765",
            "/Python": "pdfs merged and pages and words counted with Python PyPDF2"
        }
    )
The DocumentInformation Class says dates are datetime objects..

https://pypdf2.readthedocs.io/en/3.0.0/m...ation.html

Though getDocumentationInfo is depreciated, I wonder if the structure is the same?
Thanks for your reply!

I set /CREATED and /MODIFIED like this, but didn't work, still get None.

"/Created": "2023 05 17",
"/Modified": "2023 06 18",

After I make the pdf, I save it then read it again in Python, then check the metadata, which shows just as I set it. It is just a dictionary.

reader = PdfReader(path2output + outputName)
# show the new metadata
print('Showing the new metadata ... ')
meta = reader.metadata    
for item in meta.items():
    print(item)
But apparently the Evince Document Viewer 42.3 can't read the dates like above either.

Not very important!
(Jun-18-2023, 10:43 PM)Pedroski55 Wrote: [ -> ]the Evince Document Viewer 42.3 can't read the dates like above
What does pdfinfo say ?

You could perhaps try the pdf date format described in qpdf. By the way the Python bindings for this is called pikepdf. Could be worth exploring.

I see the place is 中国江苏南京市. Is this where you are?
(Jun-19-2023, 05:51 AM)Gribouillis Wrote: [ -> ]
(Jun-18-2023, 10:43 PM)Pedroski55 Wrote: [ -> ]the Evince Document Viewer 42.3 can't read the dates like above
What does pdfinfo say ?

You could perhaps try the pdf date format described in qpdf. By the way the Python bindings for this is called pikepdf. Could be worth exploring.

I see the place is 中国江苏南京市. Is this where you are?

Yeah, I'm in Nanjing right now, but not much longer, going back to England soon!

I'll check the links out, see if I can get it to work. Thanks!