我有子pdf,我想建立包含在特定位置的子pdf的主pdf。这可能吗,我该怎么做。

这是图片

最佳答案

不是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");

10-07 23:31