Description
Sets the table of contents for the PDF document..
Applies to
Syntax
SetTableOfContents(PDFTableOfContents toc)
Return value
None.
Examples
This example sets the table of contents for the document:
PDFDocument lpdf_doc PDFpage lpdf_page,lpdf_page1 PDFmultilinetext lpdf_mtext PDFtableofcontents lpdf_toc PDFtableofcontentsitem lpdf_tocitem PDFtext lpdf_title,lpdf_chapter,lpdf_chapteritem PDFfont lpdf_font string ls_ssText integer li_fhandle long ll_fileLen, ll_readSize lpdf_doc = create PDFDocument lpdf_page = create PDFpage lpdf_page1 = create PDFpage lpdf_mtext = create PDFmultilinetext lpdf_toc = create PDFtableofcontents lpdf_title = create PDFtext lpdf_chapter = create PDFtext lpdf_font = create PDFfont //Set the font used in the table of contents lpdf_font.fontname = "Arial" lpdf_font.bold = true lpdf_font.italic = true lpdf_font.fontsize = 20 lpdf_toc.setfont( lpdf_font) lpdf_title.content = "Table of Content" lpdf_title.font.fontsize = 36 lpdf_title.font.bold = true lpdf_title.y = 20 lpdf_title.x = (lpdf_page.getwidth( )-lpdf_title.width)/2 //Set the title lpdf_toc.settitle( lpdf_title) lpdf_chapter.content = "chapter1" lpdf_chapteritem = lpdf_chapter.clone( ) lpdf_chapteritem.content = "chapter1.1" //Get the content for the PDF document ll_fileLen = FileLength64("testdocument.txt") li_fhandle = fileopen("testdocument.txt", textMode! ) blob readByte ll_readSize = fileReadEx(li_fhandle, readByte,ll_fileLen) ls_ssText = string(readByte) fileclose(li_fhandle) lpdf_mtext.width = lpdf_page.getwidth( ) lpdf_mtext.content = ls_ssText //Add level-1 toc item lpdf_tocitem = lpdf_toc.additem( lpdf_chapter) //Add level-2 toc item lpdf_tocitem.additem(lpdf_chapteritem ) lpdf_page.addcontent( lpdf_chapter) lpdf_page.addcontent( lpdf_chapteritem) lpdf_page.addcontent( lpdf_mtext) lpdf_doc.addpage( lpdf_page) //Set the toc margins lpdf_toc.SetLeftMargin(100) lpdf_toc.SetTopMargin(100) lpdf_toc.SetRightMargin(100) lpdf_toc.SetBottomMargin(100) //PDFTableOfContentsStyle_Simple! /*simple toc: title 1 */ // PDFTableOfContentsStyle_Classic! /*classic toc:title.........1 */ lpdf_toc.setstyle( PDFTableOfContentsStyle_Simple!) lpdf_doc.settableofcontents( lpdf_toc) lpdf_doc.save( "D:\tocitem.pdf")
See also