Skip to main content

Command Palette

Search for a command to run...

Extract PDF Metadata with PyMuPDF in Python

Updated
2 min readView as Markdown
Extract PDF Metadata with PyMuPDF in Python
P
PDF Python Hub is dedicated to teaching PDF programming, automation, and engineering with Python through practical, project-based courses. Whether you're a complete beginner or an experienced Python developer, the goal is to help you build the skills needed to work with PDF documents confidently—from reading and extracting data to building enterprise document processing and AI-powered workflows. What You'll Learn The curriculum covers every stage of PDF processing, including: -PDF fundamentals -Document extraction -PDF manipulation -Forms, tables, and images -OCR and scanned documents -Security and redaction -Enterprise automation -AI-powered document processing How You'll Learn Every course is designed to be: -Beginner-friendly with clear, step-by-step explanations -Focused on practical, real-world applications -Built around hands-on projects and assessments -Structured as a complete learning path from beginner to expert Our Mission Our mission is simple: To make PDF processing with Python accessible, practical, and enjoyable by teaching real skills that can be applied to everyday automation tasks and professional software development. Whether you're learning for your career, your business, or your own projects, you'll gain the knowledge and confidence to build powerful PDF automation solutions with Python. Learn more: https://payhip.com/PDFPythonHub/blog/news

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

Store the metadata

metadata = doc.metadata

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

print(metadata)

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

metadata = doc.metadata

print(metadata)

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]


More PDF Python Resources

Want to learn how to open a PDF file?

Check out this mini-guide:

Open Your First PDF with PyMuPDF

More from this blog

P

PDF Python Hub

10 posts

We publish beginner-friendly Python and PDF tutorials, complete learning paths, and Google Colab notebooks.