PDFtoolkit VCL如何在Delphi或C++ Builder下合并多个PDF文档

作者:控件中国网   出处:控件中国网   2015-07-27 10:26:13   阅读:20

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);

Copyright© 2006-2015 ComponentCN.com all rights reserved.重庆磐岩科技有限公司(控件中国网) 版权所有 渝ICP备12000264号 法律顾问:元炳律师事务所
客服软件
live chat