简体   繁体   English

在现有 PDF 上插入 PDF 页面

[英]Inserting PDF Page on Existing PDF

I'm trying to insert two pdfs, the first pdf is the main pdf and the second is the one I'd like to take and append to the first pdf, under the same name. I'm trying to insert two pdfs, the first pdf is the main pdf and the second is the one I'd like to take and append to the first pdf, under the same name. The goal is to open the pdf and append and that's it.目标是打开 pdf 和 append 就是这样。

import fitz
doc1 = fitz.open("test1.pdf")
doc2 = fitz.open("test2.pdf")
doc1.insertPDF(doc2)
doc2.save("test2.pdf")

I get the error我得到错误

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\*****\AppData\Roaming\Python\Python37\site-packages\fitz\fitz.py", line 3537, in save
    raise ValueError("save to original must be incremental")
ValueError: save to original must be incremental

If there's any other way to do this please let me know, through Python如果还有其他方法可以做到这一点,请通过 Python 告诉我

If you just need to append your modifications to the existing pdf file (incremental save) you can use saveIncr() method which internally calls the save method with the correct arguments.如果您只需要 append 您对现有 pdf 文件的修改(增量保存) ,您可以使用saveIncr()方法,该方法在内部调用具有正确 ZDBC11CAA5BDA99F77E6FB4DABD882E7Z 的save方法。

saveIncr() saves the document incrementally by calling saveIncr()通过调用增量保存文档

doc.save(doc.name, incremental=True, encryption=PDF_ENCRYPT_KEEP)

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

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