var
oldpagecount: Integer;
function GetOutlineIndex(QPL: TQuickPDF; OutlineID: Integer): Integer;
var
i: Integer;
begin
Result := 0;
with QPL do
begin
for i := 1 to OutlineCount do
{$IF LibVerNum >= 7.23}
if CompareOutlines(GetOutlineID(i), OutlineID) = 1 then
begin
Result := i;
Exit;
end;
{$IFEND}
end;
end;
procedure MergeOutlines(QPL: TQuickPDF; DocumentID: Integer;
PageOldCount: Integer);
type
TOutline = record
Title: AnsiString;
Page: Integer;
DestPage, DestType: Integer;
Left, Top, Right, Bottom, Zoom: Double;
ColorRed, ColorGreen, ColorBlue: Double;
StyleBold, StyleItalic: Integer;
JavaScript, OpenFile, WebLink: String;
Parent: Integer;
end;
var
i: Integer;
seldoc: Integer;
outlineoldcount: Integer;
outlineindex, outlineid: Integer;
outlines: array of TOutline;
begin
with QPL do
begin
seldoc := SelectedDocument;
outlineoldcount := OutlineCount;
SelectDocument(DocumentID);
for i := 1 to OutlineCount do
begin
SetLength(outlines, i+1);
outlineid := GetOutlineID(i);
outlines.Title := OutlineTitle(outlineid);
outlines.Page := GetOutlinePage(outlineid) +
PageOldCount;
outlines.DestPage := GetDestPage(GetOutlineDest(outlineid)) +
PageOldCount;
outlines.DestType := GetDestType(GetOutlineDest(outlineid));
outlines.Left := GetDestValue(GetOutlineDest(outlineid), 1);
outlines.Top := GetDestValue(GetOutlineDest(outlineid), 2);
outlines.Right := GetDestValue(GetOutlineDest(outlineid), 3);
outlines.Bottom := GetDestValue(GetOutlineDest(outlineid), 4);
outlines.Zoom := GetDestValue(GetOutlineDest(outlineid), 5);
outlines.ColorRed := GetOutlineColor(outlineid, 0);
outlines.ColorGreen := GetOutlineColor(outlineid, 1);
outlines.ColorBlue := GetOutlineColor(outlineid, 2);
outlines.StyleBold := (GetOutlineStyle(outlineid) and 2) shr 1;
outlines.StyleItalic := GetOutlineStyle(outlineid) and 1;
outlines.JavaScript := GetOutlineJavaScript(outlineid);
outlines.OpenFile := GetOutlineOpenFile(outlineid);
outlines.WebLink := GetOutlineWebLink(outlineid);
// searching for parent outline
outlineindex := GetOutlineIndex(QPL, GetParentOutline(outlineid));
if outlineindex <> 0 then
outlines.Parent := outlineindex + outlineoldcount;
end;
SelectDocument(seldoc);
for i := 1 to Length(outlines) - 1 do
begin
outlineid := NewOutline(GetOutlineID(outlines.Parent),
outlines.Title, outlines.Page, 0);
SetOutlineDestinationFull(outlineid, outlines.DestPage,
Round(outlines.Zoom), outlines.DestType, outlines.Left,
outlines.Top, outlines.Right, outlines.Bottom);
SetOutlineColor(outlineid, outlines.ColorRed,
outlines.ColorGreen, outlines.ColorBlue);
SetOutlineStyle(outlineid, outlines.StyleItalic,
outlines.StyleBold);
if outlines.JavaScript <> '' then
SetOutlineJavaScript(outlineid, outlines.JavaScript);
if outlines.OpenFile <> '' then
SetOutlineOpenFile(outlineid, outlines.OpenFile);
if outlines.WebLink <> '' then
SetOutlineWebLink(outlineid, outlines.WebLink);
end;
end;
end;
begin
// create and unlock PDFLibrary here and load some PDF to merge to...
with PDFLibrary do
begin
with TOpenDialog.Create(nil) do
begin
if not Execute then
Exit;
LoadFromFile(FileName); // to merge
LoadFromFile(FileName); // to copy outlines from
Free;
end;
SelectDocument(GetDocumentID(DocumentCount - 2));
oldpagecount := PageCount;
MergeDocument(GetDocumentID(DocumentCount - 1));
SelectDocument(GetDocumentID(DocumentCount - 1));
MergeOutlines(PDFLibrary, GetDocumentID(DocumentCount), oldpagecount);
end;
// here output PDF can be saved or rendered...
end;