0

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.

simone viozzi
  • 440
  • 5
  • 18

1 Answers1

1

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.

Jorj McKie
  • 2,062
  • 1
  • 13
  • 17