Components for Developers
© 2000-2012, Two Pilots

PDF Library Download Features Manual Tutorials FAQ Pricing HTML2PDF-X Pilot History In the Lab

PDF Creator Pilot documentation

Download CHM version of this manual.
Outlines
Collapse All

This method adds a new tree node to a tree of the outline items after the specified node (the previous sibling) along with an ASCII title.

Syntax

LONG AddOutlineAfter (
LONG outlineNode,
BSTR title,
FontCharset charset
)
Parameters
outlineNode
Number of the outline node

title
ASCII title of the node

charset
Character set of the title

Return value
Number of the new node

Remarks

The number of the outline node can be retrieved from any node creating method, such as AddOutlineAfter, AddOutlineChild, GetNextSiblingOutline, and so on.

Example

Managing Outlines

Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
PDF.ViewerMode := mtUseOutlines;
ch := fcDefault;

{ adding outlines }
outline1 := PDF.AddOutlineChild(PDF.GetRootOutline, 'Outline 1', ch);
outline3 := PDF.AddOutlineAfter(outline1, 'Outline 3', ch);
outline2 := PDF.AddOutlineBefore(outline3, 'Outline 2', ch);
outline4 := PDF.AddOutlineAfter(outline3, 'Outline 4', ch);
if 'Outline 4' = PDF.GetOutlineUnicodeTitle(outline4) then
  PDF.DeleteOutline(outline4, false);

{ adding child nodes }
outline := outline1;
n := PDF.GetOutlineCount();
for i := 1 to n do
begin
    PDF.AddOutlineChild(outline, 'Child ' + IntToStr(3*(i-1)+1), ch);
    PDF.AddOutlineChild(outline, 'Child ' + IntToStr(3*(i-1)+2), ch);
    PDF.AddOutlineChild(outline, 'Child ' + IntToStr(3*(i-1)+3), ch);
    outline := PDF.GetNextSiblingOutline(outline);
end;

{ assigning actions }
action := PDF.CreateJavascriptAction('app.alert("Hello.")');
outline := outline1;
n := PDF.GetOutlineCount();
for i := 1 to n do
begin;
    PDF.SetOutlineAction(outline, action);
    outline := PDF.GetNextOutline(outline);
end;

{ changing node's text }
n := PDF.GetOutlineChildCount(outline3);
for i := 0 to n-1 do
begin;
    outline := PDF.GetOutlineChild(outline3, i);
    if outline = PDF.GetOutlineFirstChild(outline3) then
       PDF.SetOutlineTitle(outline, 'Node''s first child.', ch)
    else
       if outline = PDF.GetOutlineLastChild(outline3) then
          PDF.SetOutlineTitle(outline, 'Node''s last child.', ch)
       else
          PDF.SetOutlineTitle(outline, 'Node''s child.', ch)
end;

if PDF.IsOutlineExpanded(outline3) then
   PDF.SetOutlineExpanded(outline3, false);

PDF.SaveToFile('test.pdf', true);
C/C++
[copy to clipboard]
// PDF object is supposed to be created
PDF->ViewerMode = mtUseOutlines;
FontCharset ch = fcDefault;

// adding outlines
long outline1 = PDF->AddOutlineChild(PDF.GetRootOutline, "Outline 1", ch);
long outline3 = PDF->AddOutlineAfter(outline1, "Outline 3", ch);
long outline2 = PDF->AddOutlineBefore(outline3, "Outline 2", ch);
long outline4 = PDF->AddOutlineAfter(outline3, "Outline 4", ch);
if (L"Outline 4" == PDF->GetOutlineUnicodeTitle(outline4))
   PDF->DeleteOutline(outline4, false);

// adding child nodes
long outline = outline1;
long n = PDF->GetOutlineCount();
for (long i = 0; i < 3*n; i++)
{
    PDF->AddOutlineChild(outline, "Child " & i, ch);
    PDF->AddOutlineChild(outline, "Child " & i+1, ch);
    PDF->AddOutlineChild(outline, "Child " & i+2, ch);
    outline = PDF->GetNextSiblingOutline(outline);
    i = i + 2;
}

// assigning actions
long action = PDF->CreateJavascriptAction("app.alert('Hello.')");
outline = outline1;
n = PDF->GetOutlineCount();
for (long i = 0; i < n; i++)
{
    PDF->SetOutlineAction(outline, action);
    outline = PDF->GetNextOutline(outline);
}

// changing node's text
n = PDF->GetOutlineChildCount(outline3);
for (long i = 0; i < n; i++)
{
    outline = PDF->GetOutlineChild(outline3, i);
    if (outline == PDF->GetOutlineFirstChild(outline3))
       PDF->SetOutlineTitle(outline, "Node's first child.", ch);
    else
    {
       if (outline == PDF->GetOutlineLastChild(outline3))
          PDF->SetOutlineTitle(outline, "Node's last child.", ch);
       else
          PDF->SetOutlineTitle(outline, "Node's child.", ch);
    }
}

if (PDF->IsOutlineExpanded(outline3))
   PDF->SetOutlineExpanded(outline3, false);

PDF->SaveToFile("test.pdf", true);
C#