2012-03-01 76 views
4

我找不到这样做的方式。我需要的是一页作为背景,另一页作为前景。如何将两个pdf页面与pdfbox(java)连接起来?

+1

定义合并...一个pdf在另一个文档中跟着另一个? – 2012-03-01 14:17:08

+0

一页作为背景,另一页作为背景 – user1242789 2012-03-01 14:19:24

+0

如果你想要一个更多的例子,请查看我的答案:http://stackoverflow.com/a/33778107/5576194 – Emil 2015-11-18 10:58:13

回答

3

我找到了!

LayerUtility lu = new LayerUtility(doc); 
PDXObjectForm form = lu.importPageAsForm(doc2, 0); 
PDPage page = (PDPage) doc.getDocumentCatalog().getAllPages().get(0); 
lu.wrapInSaveRestore(page); 
AffineTransform at = new AffineTransform(); 
lu.appendFormAsLayer(page, form, at, "new_layer_name"); 
+0

如果你正在合并的PDF文件有什么不同的页面大小?它破坏输出 - 使用比导入图层更小的基本PDF进行测试。需要设置大小或改变mediabox/cropbox值我猜。 – 2013-07-15 14:47:04