在特定位置将多个pdf构建为单个pdf

时间:2014-10-20 05:47:14

标签: java pdf

我有子pdf,我想建立主要pdf,包括特定位置的子pdf。这是可能的,我该怎么做。

这是图像 enter image description here

2 个答案:

答案 0 :(得分: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");

答案 1 :(得分:0)

对于纯Java解决方案,请查看mkl的建议。

我尝试了PDFBox solutionPDFClown solution。两者都很好。在我看来,PDFClown更简单,因此在完成任务时不那么乏味。例如,坐标较少,这肯定有助于安排多页。