p in [input.getPage(i) for i in range(0,input.getNumPages())]: (w, h) = p.mediaBox.upperRightp.mediaBox.upperRight = (w/2, h) output.addPage(p)| 3 | 4 |
+-------+----
我有一个PDF文档,我想要复制,当我复制它时,我想调整页面的大小到自定义大小。例如,原始文档的页数为8 1/2 x16,新文档需要在22之前为8 1/2。新文档中的8 1/2来自原始文档的宽度;22是固定的(常量)。使问题复杂化的是,新文档需要在页面上以旧文档内容为中心。' Finally, write the updated mediabox back to the dictionary -> to th