René's URL Explorer Experiment


Title: How to Work With a PDF in Python – Real Python

Open Graph Title: How to Work With a PDF in Python – Real Python

Description: In this step-by-step tutorial, you'll learn how to work with a PDF in Python. You'll see how to extract metadata from preexisting PDFs . You'll also learn how to merge, split, watermark, and rotate pages in PDFs using Python and PyPDF2.

Open Graph Description: In this step-by-step tutorial, you'll learn how to work with a PDF in Python. You'll see how to extract metadata from preexisting PDFs . You'll also learn how to merge, split, watermark, and rotate pages in PDFs using Python and PyPDF2.

Mail addresses
?subject=Python article for you&body=How to Work With a PDF in Python on Real Python https://realpython.com/pdf-python/

Opengraph URL: https://realpython.com/pdf-python/

X: @realpython

direct link

Domain: realpython.com


Hey, it has json ld scripts:
{
  "@context": "http://schema.org",
  "@type": "Article",
  "headline": "How to Work With a PDF in Python",
  "image": {
    "@type": "ImageObject",
    "url": "https://files.realpython.com/media/How-to-Work-with-a-PDF-in-Python_Watermarked.dde4bda18f7d.jpg",
    "width": 1920,
    "height": 1080
  },
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "https://realpython.com/pdf-python/",
    "lastReviewed": "2026-10-15",
    "author": {
      "@type": "Person",
      "name": "Mike Driscoll",
      "image": "https://realpython.com/cdn-cgi/image/width=900,height=900,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/mdriscoll.db44df0df864.jpg",
      "url": "https://realpython.com/team/mdriscoll/",
      "affiliation": {
        "@type": "Organization",
        "@id": "https://realpython.com/#organization",
        "name": "Real Python",
        "url": "https://realpython.com",
        "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
      }
    },
    "reviewedBy": [
      {
        "@type": "Person",
        "name": "Aldren Santos",
        "image": "https://realpython.com/cdn-cgi/image/width=500,height=500,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Aldren_Santos_Real_Python.6b0861d8b841.png",
        "url": "https://realpython.com/team/asantos/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Brad Solomon",
        "image": "https://realpython.com/cdn-cgi/image/width=1188,height=1188,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Screen_Shot_2021-09-28_at_3.13.21_PM.3310c56e90bd.jpg",
        "url": "https://realpython.com/team/bsolomon/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Joanna Jablonski",
        "image": "https://realpython.com/cdn-cgi/image/width=800,height=800,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/jjablonksi-avatar.e37c4f83308e.jpg",
        "url": "https://realpython.com/team/jjablonski/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      }
    ]
  },
  "datePublished": "2019-04-17T14:00:00+00:00",
  "dateModified": "2026-10-15T19:56:12.384497+00:00",
  "publisher": {
    "@type": "Organization",
    "@id": "https://realpython.com/#organization",
    "name": "Real Python",
    "url": "https://realpython.com",
    "logo": {
      "@type": "ImageObject",
      "url": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png",
      "width": 512,
      "height": 512
    },
    "description": "Real Python is a leading provider of online Python education and one of the largest language-specific online communities for software developers. It publishes high-quality learning resources, such as tutorials, books, and courses to an audience of millions of developers, data scientists, and machine learning engineers each month.",
    "slogan": "Become a Python Expert",
    "email": "info@realpython.com",
    "sameAs": [
      "https://github.com/realpython",
      "https://www.youtube.com/realpython",
      "https://twitter.com/realpython",
      "https://x.com/realpython",
      "https://www.linkedin.com/company/realpython-com/",
      "https://www.facebook.com/learnrealpython",
      "https://www.instagram.com/realpython",
      "https://www.tiktok.com/@realpython.com"
    ]
  },
  "author": {
    "@type": "Person",
    "name": "Mike Driscoll",
    "image": "https://realpython.com/cdn-cgi/image/width=900,height=900,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/mdriscoll.db44df0df864.jpg",
    "url": "https://realpython.com/team/mdriscoll/",
    "affiliation": {
      "@type": "Organization",
      "@id": "https://realpython.com/#organization",
      "name": "Real Python",
      "url": "https://realpython.com",
      "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
    }
  },
  "description": "In this step-by-step tutorial, you'll learn how to work with a PDF in Python. You'll see how to extract metadata from preexisting PDFs . You'll also learn how to merge, split, watermark, and rotate pages in PDFs using Python and PyPDF2."
}

authorReal Python
theme-color#18354c
color-schemelight dark
twitter:cardsummary_large_image
twitter:imagehttps://files.realpython.com/media/How-to-Work-with-a-PDF-in-Python_Watermarked.dde4bda18f7d.jpg
og:imagehttps://files.realpython.com/media/How-to-Work-with-a-PDF-in-Python_Watermarked.dde4bda18f7d.jpg
twitter:creator@realpython
og:typearticle
og:site_nameReal Python
apple-mobile-web-app-titleReal Python

Links:

https://realpython.com/
Start Herehttps://realpython.com/start-here/
Learn Python https://realpython.com/pdf-python/
Your Learning Plan →Your personalized Python learning planhttps://realpython.com/account/learning-plan/
Python Tutorials →In-depth articles and video courseshttps://realpython.com/search?kind=article&kind=course&order=newest&_from=nav_library
Learning Paths →Guided study plans for accelerated learninghttps://realpython.com/learning-paths/
Quizzes & Exercises →Check your learning progresshttps://realpython.com/search?kind=exercise&kind=quiz&_from=nav_library
Browse Topics →Focus on a specific area or skill levelhttps://realpython.com/tutorials/all/
Reference →Concise definitions for common Python termshttps://realpython.com/ref/
Mentor AI →NewYour personal Python mentorhttps://realpython.com/mentor/
Office Hours →Live Q&A calls with Python expertshttps://realpython.com/office-hours/
Community Chat →Learn with other Pythonistashttps://realpython.com/community/
Live Courses →Live, instructor-led Python courseshttps://realpython.com/live/
Books →Round out your knowledge and learn offlinehttps://realpython.com/products/books/
Podcast →Hear what’s new in the world of Pythonhttps://realpython.com/podcasts/rpp/
Unlock All Content and Become a Python Expert →Get unlimited access to all Real Python has to offerhttps://realpython.com/account/join/?from=navbar_learn
Unlock All Content →Become a Python Experthttps://realpython.com/account/join/?from=navbar_learn
More https://realpython.com/pdf-python/
Learner Storieshttps://realpython.com/learner-stories/
Python Newsletterhttps://realpython.com/newsletter/
Python Job Boardhttps://www.pythonjobshq.com
Meet the Teamhttps://realpython.com/team/
Become a Contributorhttps://realpython.com/jobs/
Searchhttps://realpython.com/search
https://realpython.com/search
Joinhttps://realpython.com/account/join/
Sign‑Inhttps://realpython.com/account/login/?intent=navbar&next=%2Fpdf-python%2F
Browse Topicshttps://realpython.com/tutorials/all/
Guided Learning Pathshttps://realpython.com/learning-paths/
Basicshttps://realpython.com/search?level=basics&_from=sidebar_level
Intermediatehttps://realpython.com/search?level=intermediate&_from=sidebar_level
Advancedhttps://realpython.com/search?level=advanced&_from=sidebar_level
aihttps://realpython.com/tutorials/ai/
algorithmshttps://realpython.com/tutorials/algorithms/
apihttps://realpython.com/tutorials/api/
best-practiceshttps://realpython.com/tutorials/best-practices/
careerhttps://realpython.com/tutorials/career/
communityhttps://realpython.com/tutorials/community/
databaseshttps://realpython.com/tutorials/databases/
data-sciencehttps://realpython.com/tutorials/data-science/
data-structureshttps://realpython.com/tutorials/data-structures/
data-vizhttps://realpython.com/tutorials/data-viz/
devopshttps://realpython.com/tutorials/devops/
djangohttps://realpython.com/tutorials/django/
dockerhttps://realpython.com/tutorials/docker/
editorshttps://realpython.com/tutorials/editors/
flaskhttps://realpython.com/tutorials/flask/
front-endhttps://realpython.com/tutorials/front-end/
gamedevhttps://realpython.com/tutorials/gamedev/
guihttps://realpython.com/tutorials/gui/
machine-learninghttps://realpython.com/tutorials/machine-learning/
newshttps://realpython.com/tutorials/news/
numpyhttps://realpython.com/tutorials/numpy/
projectshttps://realpython.com/tutorials/projects/
pythonhttps://realpython.com/tutorials/python/
stdlibhttps://realpython.com/tutorials/stdlib/
testinghttps://realpython.com/tutorials/testing/
toolshttps://realpython.com/tutorials/tools/
web-devhttps://realpython.com/tutorials/web-dev/
web-scrapinghttps://realpython.com/tutorials/web-scraping/
Table of Contentshttps://realpython.com/pdf-python/#toc
History of pyPdf, PyPDF2, and PyPDF4https://realpython.com/pdf-python/#history-of-pypdf-pypdf2-and-pypdf4
pdfrw: An Alternativehttps://realpython.com/pdf-python/#pdfrw-an-alternative
Installationhttps://realpython.com/pdf-python/#installation
How to Extract Document Information From a PDF in Pythonhttps://realpython.com/pdf-python/#how-to-extract-document-information-from-a-pdf-in-python
How to Rotate Pageshttps://realpython.com/pdf-python/#how-to-rotate-pages
How to Merge PDFshttps://realpython.com/pdf-python/#how-to-merge-pdfs
How to Split PDFshttps://realpython.com/pdf-python/#how-to-split-pdfs
How to Add Watermarkshttps://realpython.com/pdf-python/#how-to-add-watermarks
How to Encrypt a PDFhttps://realpython.com/pdf-python/#how-to-encrypt-a-pdf
Conclusionhttps://realpython.com/pdf-python/#conclusion
Further Readinghttps://realpython.com/pdf-python/#further-reading
https://realpython.com/feedback/survey/article/pdf-python/liked/?from=article-sidebar
https://realpython.com/feedback/survey/article/pdf-python/disliked/?from=article-sidebar
How to Work With a PDF in Python 31m · 6 lessons https://realpython.com/courses/pdf-python/
Mike Driscollhttps://realpython.com/pdf-python/#author
https://realpython.com/pdf-python/#reader-comments
intermediatehttps://realpython.com/tutorials/intermediate/
toolshttps://realpython.com/tutorials/tools/
History of pyPdf, PyPDF2, and PyPDF4https://realpython.com/pdf-python/#history-of-pypdf-pypdf2-and-pypdf4
pdfrw: An Alternativehttps://realpython.com/pdf-python/#pdfrw-an-alternative
Installationhttps://realpython.com/pdf-python/#installation
How to Extract Document Information From a PDF in Pythonhttps://realpython.com/pdf-python/#how-to-extract-document-information-from-a-pdf-in-python
How to Rotate Pageshttps://realpython.com/pdf-python/#how-to-rotate-pages
How to Merge PDFshttps://realpython.com/pdf-python/#how-to-merge-pdfs
How to Split PDFshttps://realpython.com/pdf-python/#how-to-split-pdfs
How to Add Watermarkshttps://realpython.com/pdf-python/#how-to-add-watermarks
How to Encrypt a PDFhttps://realpython.com/pdf-python/#how-to-encrypt-a-pdf
Conclusionhttps://realpython.com/pdf-python/#conclusion
Further Readinghttps://realpython.com/pdf-python/#further-reading
Remove adshttps://realpython.com/account/join/
How to Work With a PDF in Pythonhttps://realpython.com/courses/pdf-python/
open standardhttps://www.iso.org/standard/51502.html
pure-Pythonhttps://stackoverflow.com/questions/45976946/what-is-pure-python
Get a sample chapter from Python Tricks: The Bookhttps://realpython.com/bonus/python-tricks-sample/
https://realpython.com/pdf-python/#history-of-pypdf-pypdf2-and-pypdf4
pyPdfhttps://pypi.org/project/pyPdf/
Phasithttp://phaseit.net/
PyPDF2https://pypi.org/project/PyPDF2/
PyPDF3https://pypi.org/project/PyPDF3/
PyPDF4https://pypi.org/project/PyPDF2/
pyPdf for Python 3http://github.com/mfenniak/pyPdf/tree/py3
PyPDF4https://github.com/claird/PyPDF4
Remove adshttps://realpython.com/account/join/
https://realpython.com/pdf-python/#pdfrw-an-alternative
pdfrwhttps://github.com/pmaupin/pdfrw
ReportLabhttps://www.reportlab.com/
https://realpython.com/pdf-python/#installation
https://realpython.com/pdf-python/#how-to-extract-document-information-from-a-pdf-in-python
Leanpubhttps://leanpub.com/reportlab
importhttps://realpython.com/absolute-vs-relative-python-imports/
Python’s F-String for String Interpolation and Formattinghttps://realpython.com/python-f-strings/
variablehttps://realpython.com/python-variables/
printhttps://realpython.com/python-print/
PDFMinerhttps://github.com/euske/pdfminer
Remove adshttps://realpython.com/account/join/
https://realpython.com/pdf-python/#how-to-rotate-pages
landscape modehttps://techterms.com/definition/pageorientation
articlehttps://realpython.com/jupyter-notebook-introduction/
importhttps://realpython.com/python-import/
file-like objecthttps://docs.python.org/3/glossary.html#term-file-object
https://realpython.com/pdf-python/#how-to-merge-pdfs
Python’s argparsehttps://realpython.com/command-line-interfaces-python-argparse/
Remove adshttps://realpython.com/account/join/
https://realpython.com/pdf-python/#how-to-split-pdfs
https://realpython.com/pdf-python/#how-to-add-watermarks
https://realpython.com/pdf-python/#how-to-encrypt-a-pdf
pdflib.comhttps://www.pdflib.com/pdf-knowledge-base/pdf-password-security/encryption/
paper on the topichttps://www.cs.cmu.edu/~dst/Adobe/Gallery/PDFsecurity.pdf
Remove adshttps://realpython.com/account/join/
https://realpython.com/pdf-python/#conclusion
pdfrwhttps://github.com/pmaupin/pdfrw
https://realpython.com/pdf-python/#further-reading
The PyPDF2 websitehttps://pythonhosted.org/PyPDF2/
The Github page for PyPDF4https://github.com/claird/PyPDF4
The Github page for pdfrwhttps://github.com/pmaupin/pdfrw
The ReportLab websitehttps://www.reportlab.com/
The Github page for PDFMinerhttps://github.com/euske/pdfminer
Camelot: PDF Table Extraction for Humanshttps://github.com/socialcopsdev/camelot
Docling vs LlamaParse: How to Extract PDF Tables in Pythonhttps://realpython.com/extract-table-from-pdf-python/
Creating and Modifying PDF Files in Python (Tutorial)https://realpython.com/creating-modifying-pdf/
https://realpython.com/feedback/survey/article/pdf-python/liked/?from=article-footer
https://realpython.com/feedback/survey/article/pdf-python/disliked/?from=article-footer
How to Work With a PDF in Pythonhttps://realpython.com/courses/pdf-python/
https://realpython.com/team/mdriscoll/
» More about Mikehttps://realpython.com/team/mdriscoll/
https://realpython.com/team/asantos/
Aldrenhttps://realpython.com/team/asantos/
https://realpython.com/team/bsolomon/
Bradhttps://realpython.com/team/bsolomon/
https://realpython.com/team/jjablonski/
Joannahttps://realpython.com/team/jjablonski/
Level Up Your Python Skills »https://realpython.com/account/join/?utm_source=rp_article_footer&utm_content=pdf-python
Level Up Your Python Skills »https://realpython.com/account/join/?utm_source=rp_article_footer&utm_content=pdf-python
https://realpython.com/feedback/survey/article/pdf-python/liked/?from=article-comments
https://realpython.com/feedback/survey/article/pdf-python/disliked/?from=article-comments
LinkedInhttps://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Frealpython.com%2Fpdf-python%2F
Twitterhttps://twitter.com/intent/tweet/?text=Interesting%20Python%20article%20on%20%40realpython%3A%20How%20to%20Work%20With%20a%20PDF%20in%20Python&url=https%3A%2F%2Frealpython.com%2Fpdf-python%2F
Blueskyhttps://bsky.app/intent/compose?text=Interesting%20Python%20article%20on%20%40realpython.com%3A%20How%20to%20Work%20With%20a%20PDF%20in%20Python%20https%3A%2F%2Frealpython.com%2Fpdf-python%2F
Facebookhttps://facebook.com/sharer/sharer.php?u=https%3A%2F%2Frealpython.com%2Fpdf-python%2F
Get tips for asking good questionshttps://realpython.com/python-beginner-tips/#tip-9-ask-good-questions
get answers to common questions in our support portalhttps://support.realpython.com
Real Python Community Chathttps://realpython.com/community/
“Office Hours” Live Q&A Sessionhttps://realpython.com/office-hours/
intermediatehttps://realpython.com/tutorials/intermediate/
toolshttps://realpython.com/tutorials/tools/
How to Work With a PDF in Pythonhttps://realpython.com/courses/pdf-python/?utm_source=realpython&utm_medium=web&utm_campaign=related-course&utm_content=pdf-python
https://realpython.com/account/signup/?intent=continue_reading&utm_source=rp&utm_medium=web&utm_campaign=rwn&utm_content=v1&next=%2Fpdf-python%2F
Continue »https://realpython.com/account/signup/?intent=continue_reading&utm_source=rp&utm_medium=web&utm_campaign=rwn&utm_content=v1&next=%2Fpdf-python%2F
Sign-Inhttps://realpython.com/account/login/?intent=continue_reading&next=/pdf-python/
Start Herehttps://realpython.com/start-here/
Your Learning Planhttps://realpython.com/account/learning-plan/
Browse Topicshttps://realpython.com/tutorials/all/
Learning Resourceshttps://realpython.com/search
Python Referencehttps://realpython.com/ref/
Cheat Sheetshttps://realpython.com/cheatsheets/
Support Centerhttps://support.realpython.com
Mentor AIhttps://realpython.com/mentor/
Learning Pathshttps://realpython.com/learning-paths/
Tutorialshttps://realpython.com/tutorials/
Courseshttps://realpython.com/courses/
Quizzeshttps://realpython.com/quizzes/
Coding Exerciseshttps://realpython.com/coding-exercises/
Live Courseshttps://realpython.com/live/
Bookshttps://realpython.com/books/
Data Sciencehttps://realpython.com/start/data-science-analytics/
AI Apps & Agentshttps://realpython.com/start/ai-apps-agents/
Machine Learninghttps://realpython.com/start/machine-learning/
Automationhttps://realpython.com/start/scripting-automation/
Web Developmenthttps://realpython.com/start/web-development-apis/
Cybersecurityhttps://realpython.com/start/cybersecurity/
Podcasthttps://realpython.com/podcasts/rpp/
Newsletterhttps://realpython.com/newsletter/
Community Chathttps://realpython.com/community/
Office Hourshttps://realpython.com/office-hours/
Learner Storieshttps://realpython.com/learner-stories/
Plans & Pricinghttps://realpython.com/account/join/
Team Planshttps://realpython.com/account/join-team/
For Businesshttps://realpython.com/account/join-team/inquiry/
For Schoolshttps://realpython.com/account/join-team/education-inquiry/
Reviewshttps://realpython.com/learner-stories/
About Ushttps://realpython.com/about/
Teamhttps://realpython.com/team/
Mission & Valueshttps://realpython.com/mission/
Editorial Guidelineshttps://realpython.com/editorial-guidelines/
Sponsorshipshttps://realpython.com/sponsorships/
Careershttps://realpython.workable.com
Press Kithttps://realpython.com/media-kit/
Merchhttps://realpython.com/merch
https://www.youtube.com/realpython
https://x.com/realpython
https://www.linkedin.com/company/realpython-com
https://www.facebook.com/LearnRealPython
https://github.com/realpython/
Privacy Policyhttps://realpython.com/privacy-policy/
Terms of Usehttps://realpython.com/terms/
Securityhttps://realpython.com/security/
Contacthttps://realpython.com/contact/
https://realpython.com/

Viewport: width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover

Robots: max-image-preview:large


URLs of crawlers that visited me.