Home > other >  Ask everybody a question about PyPDF2 module usage
Ask everybody a question about PyPDF2 module usage

Time:09-30

 
The import PyPDF2
# respectively establish pdfreader and PdfWriter
Pdffile1=open (' paper. PDF ', 'rb')
Pdffile2=open (' paper. PDF ', 'wb)
Pdfreader=PyPDF2. PdfFileReader (pdffile1)
Pdfwriter.=PyPDF2 PdfFileWriter ()

# to get the total number of pages of PDF file
Numpages=pdfreader. Numpages
# start copying Page object
For the page in the range (numpages) :
Pageobj=pdfreader. Getpages (page)
Pdfwriter. The addPage (pageobj)
Pdfwriter. Write (pdffile2)
Pdffile2. Close ()
Pdffile1. Close ()




Is like that, I want to copy the PDF document, it is in Chinese characters, and then run came after such an error, want to ask everybody how to solve this problem?

CodePudding user response:

PDF text coding problem Settings corresponding coding

CodePudding user response:

reference 1st floor JasonGe1984 response:
PDF text coding problem set down the corresponding coding

Hello, are you saying or modify the PDF document code?

CodePudding user response:

I have already solved, I directly modify the PyPDF2 utils module line 238 of the code in the database, the latin-1 changed to 'utf-8'
  • Related