Your Cart
Loading
Read PDF metadata using PyMuPDF

How to Read PDF Metadata Using PyMuPDF

If you’re working with a PyMuPDF's Document object called doc, you can access its metadata with:

metadata = doc.metadata


PyMuPDF is a Python library for working with PDF files.


What does doc.metadata mean?

doc.metadata contains additional information about the PDF document, rather than the PDF document’s main text.


It might contain information such as:

  • format
  • title
  • author
  • creator


1. Store the metadata

Store PDF Metadata with Python


This takes the metadata associated with doc and stores it in a variable called metadata.


2. Print the metadata

Printing Document Metadata with Python


This displays the metadata:

{'format': 'PDF 1.5', 'title': 'Artificial Intelligence (AI) ', 'author': 'PDF Python Hub', 'subject': 'An Overview of Artificial Intelligence, Machine Learning, Generative AI, Ethical Frameworks, and Future Outlook', 'keywords': 'Artificial Intelligence, AI, Machine Learning, Deep Learning, Generative AI, Large Language Models, AI Ethics', 'creator': 'Google Docs', 'producer': 'Skia/PDF m153 Google Docs Renderer', 'creationDate': "D:20260816101230+02'00'", 'modDate': "D:20260818145823+02'00'", 'trapped': '', 'encryption': None}


You can then access individual pieces of information:

print(metadata["author"])

print(metadata["creationDate"])



Complete Example

How to Read PDF Metadata with PyMuPDF



Open the notebook

Open the Google Colab notebook for this PDF mini-guide and run the code as you follow along.

[Open in Google Colab]




Ready to put this into practice? Check out the Python and PDF resources in our store.


👉 Visit the store




More PDF Python Resources

Want to learn how to open a PDF file?


Check out this mini-guide: Open Your First PDF with PyMuPDF.




Subscribe to our newsletter

Get notified when new PDF mini-guides, resources, templates, bundles, ebooks, and courses are released.