gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 06:28:31 28 4
gpt4 key购买 nike

我有子 pdf,我想构建由特定位置的子 pdf 组成的主 pdf。这可能吗,我该怎么做。

这是图片 enter image description here

最佳答案

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

关于java - 在特定位置将多个 pdf 构建为单个 pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26459213/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com