1. Dennis Eisler
  2. PowerBuilder
  3. Tuesday, 19 December 2023 20:29 PM UTC

Good morning/evening. I am trying to use the new PB2022R2 PDF Builder feature to add page numbers and a table of contents to a new PDF document that I generate. The documentation that describes the feature (PDF Builder enhancements - - What's New (appeon.com)) mentions "Creating links in a PDF document that points to other areas of the document"
I have reviewed the examples that describe creating PDF documents (Examples - - Application Techniques (appeon.com)) but:
- Cannot get most of them to work
- Do not see a part where you can create a page number and how to reference that page number in a table of contents (TOC)

I also can't really see whether you can reference an imported datawindow in the same way that you can reference another page in the PDF Document. I have been able to use the PDF Builder datawindow import feature to create a PDF file that has the following format:

- Title page 
- Main Table of Contents (a datawindow)
- Consolidated Summary Report
-- Each department from the main TOC
-- TOC for the department listing the financial statements 
-- Consolidated summary for the dept
--- List of individual financial statement reports

So, it is a nested format and is made up of imported datawindow reports. From the help documentation on the Appeon site, I see that the PDF Document image contains a PDFPage object which contains the PDFText objects which I guess will be used for the page numbering. I do not see PDF Datawindow Import on the PDF Builder overview page (https://docs.appeon.com/pb2022r3/application_techniques/ch08s04s01.html) but each imported DW seems to be counted as individual PDF pages when I run a PDF pagecount. 

Could anyone provide a simple example of a PDF builder script that:
- Adds a page number to an imported datawindow
- Creates a table of contents with a link to the imported datawindow's page

Thank you very much for any help or further documentation that you can provide!

Dennis

 

 

Dennis Eisler Accepted Answer Pending Moderation
  1. Tuesday, 19 December 2023 23:17 PM UTC
  2. PowerBuilder
  3. # 1

I think that I have a workable script. I can add the text object (Chapter) to the imported datawindow and then click the Table of Contents item to go to it. Hope this helps.

long 					ll_return, ll_page
string					ls_name, ls_text

PDFdocument 			        lpdf_doc
PDFpage					lpdf_page, lpdf_current_page
PDFtext 				lpdf_text, lpdf_title, lpdf_chapter
PDFTableofContents		        lpdf_toc
PDFtableofContentsitem	                lpdf_tocitem



ll_return = dw_1.Retrieve()
IF ll_return < 0   THEN
	MessageBox('Retrieve', 'Failed')
END IF

lpdf_doc 		= Create PDFdocument
lpdf_page 		= Create PDFpage
lpdf_text  		= Create PDFtext
lpdf_title  	        = Create PDFtext
lpdf_chapter 	        = Create PDFtext
lpdf_toc 		= Create PDFtableofContents

//Get the page count to locate the newly imported DW. Should be zero
ll_page = lpdf_doc.getpagecount( )
	
ll_page ++	
	
//Import the DW that we retrieved earlier	
lpdf_doc.importdatawindow( dw_1)

//Assign the DW page to lpdf_current_page
lpdf_current_page	= lpdf_doc.getPage(ll_page)
ls_name 		= lpdf_current_page.Name

//Create TOC page - From the Help Docs
lpdf_title.content = "TableOfContents"
lpdf_title.font.fontsize = 36
lpdf_title.x = lpdf_page.getwidth( )/2 -lpdf_title.width/2

lpdf_toc.setstyle(PDFTableOfContentsStyle_Classic!)
lpdf_toc.setrightmargin( 100)
lpdf_toc.setleftmargin( 100)
lpdf_toc.settopmargin( 50)
lpdf_toc.settitle(lpdf_title)

lpdf_chapter.content = "Chapter1"
lpdf_tocitem         = lpdf_toc.additem(lpdf_chapter)	//Add to the table of contents

lpdf_current_page.addcontent(lpdf_chapter)	//Add the Chapter 1 heading to the imported DW page

lpdf_doc.settableofcontents( lpdf_toc)

ll_return = lpdf_doc.save( "c:\share\pdftest.pdf")

MessageBox("Generate", "Done")

RETURN SUCCESS
Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.