PDFtoolkit VCL 是一款专门用于Delphi和C++ Builder下的PDF类文档控件,可以快速帮助开人员进行PDF文档的编辑、合并、分割、浏览、数字签名以及打印PDF文档,并且可以提取PDF文档里的文本、导出为图片等,这里主要介绍下怎么使用PDFtoolkit VCL 进行多个PDF文件的合并,具体如下:
1.首先打开创建好的Delphi/C++ Builder应用程序,然后添加PDFtoolkit控件到窗体上
2.添加一个按钮到窗体上,并且把按钮名字改为'Merge PDFs'
3.双击按钮,并且在按钮的click事件中添加如下代码:
Delphi:
Var
// Declare the string list to accept the input PDF files to be merged
LFileNames: TStringList;
begin
LFileNames := TStringList.Create;
// Add input PDF files to string list
LFileNames.Add('Doc1.pdf');
LFileNames.Add('Doc2.pdf');
LFileNames.Add('Doc3.pdf');
// Merge input PDF files
gtPDFDocument1.MergeDocs(LFileNames);
// Save merged file to Disk
gtPDFDocument1.SaveToFile('Output.pdf');
// Free string list from memory
FreeAndNil(LFileNames);
end;
C++Builder:
// Declare the string list to accept the input PDF files to be merged
TStringList *LFileNames;
// Provide filenames of documents in a string list.
LFileNames = new TStringList();
LFileNames->Add("Doc1.pdf");
LFileNames->Add("Doc2.pdf");
LFileNames->Add("Doc3.pdf");
// Merge the documents.
gtPDFDocument1->MergeDocs(LFileNames);
// Save merged file to disk.
gtPDFDocument1->SaveToFile("Output.pdf");
// Free string list from memory
Gtutils::FreeAndNil(LFileNames);