2014-10-20 21 views
1

上面有子pdf文件,我想要构建包含特定位置的子pdf文件的主要pdf文件。这是可能的,我该怎么做。在特定位置构建多个PDF文件到单个pdf文件

这里是图像 enter image description here

+0

*我想要构建包含特定位置的子pdf的主要pdf * - 我假设那些*子pdf的*只有一个页面页面,或者至少他们感兴趣的每个页面只有一个页面。在这种情况下,任何通用PDF库都应该这样做。有些PDF库明确支持(例如iText和PdfClown),而对于其他PDF功能库则很容易添加(例如PDFBox,参见[此答案](http://stackoverflow.com/a/26299557/1729265))。 – mkl 2014-10-20 08:38:04

回答

1

不是Java,但C#的解决方案 - 作为替代PDF邮票(使用Debenu Quick PDF Library):

DPL.AddToFileList("file_list", "file_1.pdf"); //file with one page 
DPL.AddToFileList("file_list", "file_2.pdf"); //file with one page 
DPL.AddToFileList("file_list", "file_3.pdf"); //file with one page 
DPL.AddToFileList("file_list", "file_4.pdf"); //file with one page 

DPL.MergeFileList("file_list", "merged_files.pdf"); //merge the files into a new document 

DPL.LoadFromFile("merged_files.pdf", ""); //load the new merged file 
DPL.InsertPages(1, 1); //it is important to add a new blank page, becasue in the next steps the CapturePage function removes the pages and the document must have at least one page - the final page 
int captured1 = DPL.CapturePage(2); 
int captured2 = DPL.CapturePage(2); //the captured page is removed, so page numbers are decreased 
int captured3 = DPL.CapturePage(2); 
int captured4 = DPL.CapturePage(2); 

DPL.SelectPage(1); 
DPL.DrawCapturedPage(captured1, 100, 200, 100, 100); //you can set your custom coordinates: left, top, widt, height 
DPL.DrawCapturedPage(captured2, 200, 200, 100, 100); 
DPL.DrawCapturedPage(captured3, 300, 200, 100, 100); 
DPL.DrawCapturedPage(captured4, 400, 200, 100, 100); 

DPL.SaveToFile("merged_files.pdf"); 
0

至于纯Java的解决方案,检查出的mkl建议。我试过PDFBox solutionPDFClown solution。两者都很好。在我看来,PDFClown更为直接,因此在完成任务时不那么繁琐。例如,有很少摆弄坐标,这当然有助于安排一个多页。