Extract PDF Metadata with PyMuPDF in Python

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 the 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.
More PDF Python Resources
Want to learn how to open a PDF file?
Check out this mini-guide:
About the author
- PDF & Python Lab 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
Comments
Join the discussionNo comments yet. Be the first to comment.



