【问题标题】:PDF - Fitz makes the merged page as flippedPDF - Fitz 使合并页面翻转
【发布时间】:2022-12-15 14:05:31
【问题描述】:

下面是我用来在 pdf 页面上添加水印的代码。在某些页面上,水印看起来像颠倒了(旋转 180 度,看起来像在镜子里)。

doc_report = fitz.open(report_pdf_path)
doc_watermark = fitz.open(watermark_pdf_path)

for i in xrange(doc_report.pageCount):
    page = doc_report.loadPage(i)
    page_front = fitz.open()
    page_front.insertPDF(doc_watermark, from_page=i, to_page=i)
    page.showPDFpage(page.rect, page_front, pno=0, keep_proportion=True, overlay=True, rotate=0, clip=None)

doc_report.save(save_path, encryption=fitz.PDF_ENCRYPT_KEEP)
doc_report.close()
doc_watermark.close()

在调试时我比较了目标页面和水印页面的旋转、变换属性,它们看起来是一样的。 你能告诉我如何解决这个问题吗?

【问题讨论】:

标签: python pdf merge


【解决方案1】:

谢谢KJ,这是解决问题的更新代码。

doc_report = fitz.open(report_pdf_path)
doc_watermark = fitz.open(watermark_pdf_path)

for i in xrange(doc_report.pageCount):
    page = doc_report.loadPage(i)
    page_front = fitz.open()
    
    # added this
    if not page._isWrapped:
        page._wrapContents()

    page_front.insertPDF(doc_watermark, from_page=i, to_page=i)
    page.showPDFpage(page.rect, page_front, pno=0, keep_proportion=True, overlay=True, rotate=0, clip=None)

doc_report.save(save_path, encryption=fitz.PDF_ENCRYPT_KEEP)
doc_report.close()
doc_watermark.close()

【讨论】:

    猜你喜欢
    • 2016-06-10
    • 1970-01-01
    • 1970-01-01
    • 2019-10-30
    • 2017-10-21
    • 1970-01-01
    • 2014-10-02
    • 1970-01-01
    • 2019-12-08
    相关资源
    最近更新 更多