【问题标题】:Pdf Imposition using Python使用 Python 拼版 PDF
【发布时间】:2017-07-20 22:40:19
【问题描述】:

我正在尝试将 pdf 的第一页和第二页强加到第 1 页。第一页将在第二页之上,强加在第一页上。

问题是页面没有修剪或合并。最后一页强加于倒数第二个,就是这样。

from PyPDF2 import PdfFileReader, PdfFileWriter


output = PdfFileWriter()

file_name = '81plots.pdf'
file = PdfFileReader(open(file_name, 'rb'))


i = 1
for i in range(file.getNumPages()):
    page = file.getPage(i-1)
    page.trimBox.LowerLeft = (0, 395.28422)
    page.trimBox.LowerRight = (1459.75542, 395.28422)
    page.trimBox.UpperLeft = (0, 790.56844)
    page.trimBox.UpperRight = (1459.75542, 790.56844)
    page_step = file.getPage(i)
    page_step.trimBox.LowerLeft = (0,0)
    page_step.trimBox.LowerRight = (1459.75542, 0)
    page_step.trimBox.UpperLeft = (0, 395.28422)
    page_step.trimBox.UpperRight = (1459.75542, 395.28422)
    page.mergePage(page_step)
    output.addPage(page)


outfile = 'testfile.pdf'

with open(outfile, 'wb') as file:
    output.write(file)

【问题讨论】:

    标签: python pdf pypdf pypdf2 imposition


    【解决方案1】:

    修剪框并不真正适用于您正在尝试做的事情。

    我建议你从一个空白页面开始,使用PageObject类的mergeScaledTranslatedPage方法将两个页面的内容放到新页面上。

    【讨论】:

      猜你喜欢
      • 2019-01-29
      • 1970-01-01
      • 2010-10-02
      • 2010-09-10
      • 2013-09-16
      • 1970-01-01
      • 2013-05-13
      • 1970-01-01
      相关资源
      最近更新 更多