This tutorial shows the three core operations of the PDF Split Merge ActiveX DLL from Delphi: splitting a document into page-range files, merging selected pages from multiple files, and rotating pages.
All operations accept a password for protected inputs and return an integer status code.
Before you start
- Install the PDF Split Merge ActiveX DLL trial.
- Create the object with
CreateOleObject('PDFSplitMergeX.SplitMergeLib'). - Call
SetLicenseKey()before the first operation. - Use ranges such as
1-3,4-6and output patterns such aspart-%d.pdf.
Complete example
procedure TForm1.Button1Click(Sender: TObject);
var
obj: OleVariant;
iRtn, iPageCount: Integer;
begin
//Create object
obj := CreateOleObject('PDFSplitMergeX.SplitMergeLib');
//Set your license key
obj.SetLicenseKey('License Code');
//Split PDF file
iRtn:= obj.Split('..\PDF-Split-Merge-ActiveX-DLL.pdf','', '1,2-3,4-5,6', '..\split-%d.pdf');
if iRtn = 1 then
begin
ShowMessage('Split Successfuly.');
end;
//Merge PDF file
iRtn:= obj.Merge('..\split-1.pdf|..\split-2.pdf?1-1', '..\merge-1.pdf');
if iRtn = 1 then
begin
ShowMessage('Merge Successfuly.');
end;
//Get Page Count
iPageCount:= obj.GetPageCount('..\PDF-Split-Merge-ActiveX-DLL.pdf', '');
Obj := Unassigned;
end;How it works
- Split output names use
%d, which is replaced by the output file number. - Merge file lists use
|as a separator and?for per-file page ranges. - Rotate accepts 90, 180 or 270 degrees.