Skip to content

Instantly share code, notes, and snippets.

@haider11234
Created January 11, 2021 07:41
Show Gist options
  • Save haider11234/b0009a8ea029d628a026fd73de413a54 to your computer and use it in GitHub Desktop.
Save haider11234/b0009a8ea029d628a026fd73de413a54 to your computer and use it in GitHub Desktop.
from PyPDF2 import PdfFileReader
pdf_file=open("sample.pdf", 'rb'):
pdf = PyPDF2.PdfFileReader(pdf_file)
information = pdf.getDocumentInfo()
number_of_pages = pdf.getNumPages()
info = f"""
Information about {pdf_path}:
Author: {information.author}
Creator: {information.creator}
Producer: {information.producer}
Subject: {information.subject}
Title: {information.title}
Number of pages: {number_of_pages}
"""
print(info)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment