简体   繁体   中英

PyMuPdf - missing addPage(page) method

i used PyPDF2 before and i wrote this class

class pdfWriter:
  fh = None
  pdf_obj = None

  def __init__(self, path):
    if(not path.endswith('.pdf')):
        path += ".pdf"
    self.fh = open(path, 'wb')
    self.pdf_obj = PdfFileWriter()

  def addPage(self, page):
    self.pdf_obj.addPage(page)

  def write(self):
    self.pdf_obj.write(self.fh)

now i'm trying to achieve the same thing using PyMuPdf but i can't find a method to add a page object to a document object.

Thanks in advance for any help.

Do this: page = doc.newPage() and you are done. There are parameters letting you choose the desired page size and also the location if the PDF already contains pages.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM