The PyPDF2 library helps merge pdf files with python. It’s easy to set up and use. Installation: pip install PyPDF2. We have a folder under the name of “PDFsToMerge” which has two PDF file. Oct 08, 2012 The import PyPDF2 looks for PyPDF2 folder in the base location of python. In my case it is C: Python27 site-packages PyPDF2. When virtualenv is activated, pip install PyPDF2 does not create the above folder. Viewed 1k times. I am wondering, why, for the life of me I cannot import and use PyPDF2 (PDF library) in Python 3.7. Firstly, my import fails at top of main.py (i.e. Below) from PyPDF2 import PdfFileReader. Then I have tried pip install PyPDF2 and variants pip2 install PyPDF3 etc etc.
Initializes a PdfFileReader object. This operation can take some time, asthe PDF stream’s cross-reference tables are read into memory.
Parameters: |
|
---|
decrypt
(password)¶When using an encrypted / secured PDF file with the PDF Standardencryption handler, this function will allow the file to be decrypted.It checks the given password against the document’s user password andowner password, and then stores the resulting decryption key if eitherpassword is correct.
It does not matter which password was matched. Both passwords providethe correct decryption key that will allow the document to be used withthis library.
Parameters: | password (str) – The password to match. |
---|---|
Returns: | 0 if the password failed, 1 if the password matched the userpassword, and 2 if the password matched the owner password. |
Return type: | int |
Raises NotImplementedError: | |
if document uses an unsupported encryptionmethod. |
documentInfo
¶Read-only property that accesses the getDocumentInfo()
function.
getDestinationPageNumber
(destination)¶Retrieve page number of a given Destination object
Parameters: | destination (Destination) – The destination to get page number.Should be an instance ofDestination |
---|---|
Returns: | the page number or -1 if page not found |
Return type: | int |
getDocumentInfo
()¶Retrieves the PDF file’s document information dictionary, if it exists.Note that some PDF files use metadata streams instead of docinfodictionaries, and these metadata streams will not be accessed by thisfunction.
Returns: | the document information of this PDF file |
---|---|
Return type: | DocumentInformation or None if none exists. |
getFields
(tree=None, retval=None, fileobj=None)¶Extracts field data if this PDF contains interactive form fields.The tree and retval parameters are for recursive use.
Parameters: | fileobj – A file object (usually a text file) to writea report to on all interactive form fields found. |
---|---|
Returns: | A dictionary where each key is a field name, and eachvalue is a Field object. Bydefault, the mapping name is used for keys. |
Return type: | dict, or None if form data could not be located. |
getFormTextFields
()¶Retrieves form fields from the document with textual data (inputs, dropdowns)
getNamedDestinations
(tree=None, retval=None)¶Retrieves the named destinations present in the document.
Returns: | a dictionary which maps names toDestinations . |
---|---|
Return type: | dict |
getNumPages
()¶Calculates the number of pages in this PDF file.
Returns: | number of pages |
---|---|
Return type: | int |
Raises PdfReadError: | |
if file is encrypted and restrictions preventthis action. |
getOutlines
(node=None, outlines=None)¶Retrieves the document outline present in the document.
Returns: | a nested list of Destinations . |
---|
getPage
(pageNumber)¶Retrieves a page by number from this PDF file.
Parameters: | pageNumber (int) – The page number to retrieve(pages begin at zero) |
---|---|
Returns: | a PageObject instance. |
Return type: | PageObject |
getPageLayout
()¶Get the page layout.See setPageLayout()
for a description of valid layouts.
Returns: | Page layout currently being used. |
---|---|
Return type: | str , None if not specified |
getPageMode
()¶Get the page mode.See setPageMode()
for a description of valid modes.
Returns: | Page mode currently being used. |
---|---|
Return type: | str , None if not specified |
getPageNumber
(page)¶Retrieve page number of a given PageObject
Parameters: | page (PageObject) – The page to get page number. Should bean instance of PageObject |
---|---|
Returns: | the page number or -1 if page not found |
Return type: | int |
getXmpMetadata
()¶Install Pypdf2 Python Anaconda
Retrieves XMP (Extensible Metadata Platform) data from the PDF documentroot.
Returns: | a XmpInformation instance that can be used to access XMP metadata from the document. |
---|---|
Return type: | XmpInformation orNone if no metadata was found on the document root. |
isEncrypted
¶Read-only boolean property showing whether this PDF file is encrypted.Note that this property, if true, will remain true even after thedecrypt()
method is called.
namedDestinations
¶Read-only property that accesses thegetNamedDestinations()
function.
numPages
¶Read-only property that accesses thegetNumPages()
function.
outlines
¶- Read-only property that accesses the
getOutlines()
function.
Install Pypdf2 Python On Windows
pageLayout
¶Read-only property accessing thegetPageLayout()
method.
Install Pypdf2 Python Download
pageMode
¶Read-only property accessing thegetPageMode()
method.
pages
¶Install Pypdf2 Python On Linux
Read-only property that emulates a list based upon thegetNumPages()
andgetPage()
methods.
xmpMetadata
¶Install Pypdf2 In Python
Read-only property that accesses thegetXmpMetadata()
function.