|
Method SetOutline |
Top Previous Next |
|
Method SetOutline
This procedure creates an outline entry. It returns the id number of the just created outline entry. This id number can be used to create the next entry as the child of the current.
Please note that you can use the procedure SetOutlineCharset to define a certain charset for the outline. You can use the value 0 to select the default charset or one of the following constants: EASTEUROPE_CHARSET, RUSSIAN_CHARSET, GREEK_CHARSET , TURKISH_CHARSET and BALTIC_CHARSET.
Parameters:
const Caption : string This is the text which should be displayed in the outline tree.
const BookMarkName : string This is the name of the book mark which should be linked to this outline entry. The book mark can be already known or defined later during the export of the text. You can also use the book mark feature of WPTools. (afsBookmark text style).
aPrevious : Integer If this variable is greater 0 the outline entry will be created after the entry with give id. Note: If aParent and aPrevious are 0 the outline will be created at the top level.
aParent : Integer If this variable is greater 0 the outline entry will be created as the child of the entry with the id provided here.
Example to create dummy entries: procedure TForm1.WPPDFPrinter1BeforeEndDoc(Sender: TObject); var last,inner : Integer; i,j : Char; begin last := 0; for i:='A' to 'E' do begin Last := WPPDFPrinter1.SetOutline(i, 'DUMMY',last, 0); inner := 0; for j := 'A' to 'Z' do inner := WPPDFPrinter1.SetOutline(i+'.'+j, 'DUMMY', inner, Last); end; end;
Parameters Example: Create test outline. This code for the event OnAfterPrintPage will create some dummy information to test the outline feature.
Please see SetOutlineXY for example code.
This example code can be used to export from a TTreeView component to the PDF outline. It does not add the bookmark references, you have to add the logic for that.
procedure TForm2.WPPDFExportAfterPrintPage(Sender: TObject; Number, FromPos, Length: Integer); procedure CreateOutline(Node: TTreeNode; ParentItem: Integer); var ThisItem, i: Integer; begin // Create an entry for the current Node ThisItem := WPPDFExport.SetOutline(Node.Text, '', // MISSING: bookmark for this item 0, ParentItem); // If the Node has children process them if Node.hasChildren then CreateOutline(Node.getFirstChild, ThisItem); // Only if the is the first node on this level process all the others // on the same level if Node.getPrevSibling=nil then while Node<>nil do begin Node := Node.GetNextSibling; if Node<>nil then CreateOutline(Node, ParentItem); end; end; begin CreateOutline(TreeView1.TopItem, 0); end;
|