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 codingCodePudding user response: