简体   繁体   English

PyMuPdf - 缺少 addPage(page) 方法

[英]PyMuPdf - missing addPage(page) method

i used PyPDF2 before and i wrote this class我之前使用过 PyPDF2 并且我写了这个类

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.现在我正在尝试使用 PyMuPdf 来实现相同的目的,但是我找不到将页面对象添加到文档对象的方法。

Thanks in advance for any help.在此先感谢您的帮助。

Do this: page = doc.newPage() and you are done.这样做: page = doc.newPage()就完成了。 There are parameters letting you choose the desired page size and also the location if the PDF already contains pages.如果 PDF 已包含页面,则有一些参数可让您选择所需的页面大小以及位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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