Creating Bookmarks

If you are a Power Builder developer and have any questions about using our products from Power Builder here is the place to post them.
Post Reply
eric.glenn
Posts: 11
Joined: Tue Sep 02 2008

Creating Bookmarks

Post by eric.glenn » Tue Nov 24 2009

External Function Declarations

Code: Select all

// HDC CDICreateDC( HANDLE hPrinter );
Function uLong CDICreateDC (Long hPrinter ) Library "cdintf300.dll" alias for "CDICreateDC;Ansi"

// long SetBookmark( HANDLE hDC, long lParent, LPCSTR szTitle );
Function Long SetBookmark(uLong hDC, long lParent, string szTitle ) Library "cdintf300.dll" alias for "SetBookmark;Ansi"
PowerScript

Code: Select all

// Your code for initializing Amyuni CDI print system goes here...

// --- Print ---//
long Job, x
ulong printerDC
// Start a new job and a new page.
Job = PrintOpen()
// Print the text.
x =  PrintText(Job,"The material ", 2000, 4000)
ll_rc = Print(Job, x, " in this report")
ll_rc = Print(Job, 2000, "is not confidential and ")
ll_rc = Print(Job, 2000, "may be freely disclosed ")
ll_rc = Print(Job, 2000, " ")

for ll_row = 1 to 5
	ll_rc = Print(Job, 2000, "This should be bookmark " + string( ll_row ) )
	ls_error = of_get_error()
	ll_rc = Print(Job, 2000, " ")
	printerDC = CDICreateDC (ll_pdfprinter)
	ll_rc = SetBookmark(printerDC, 0, "Bookmark " + string( ll_row ) )
	ll_rc = Print(Job, 2000, " ")
	ls_error = of_get_error()
next 
ll_rc = PrintClose(Job)

// Your code to shutdown Amyuni CDI print system goes here...
I would expect that this code would print
The material in this report
is not confidential and
may be freely disclosed

This should be bookmark 1

This should be bookmark 2

This should be bookmark 3

This should be bookmark 4

This should be bookmark 5
it does!

What it doesn't do is add 5 bookmarks.

Can you use CDICreateDC and SetBookmark with PowerBuilder?

I assumed that CDICreateDC would get a device context from the print driver and create a bookmark at each place where I invoke SetBookmark.

Devteam
Posts: 115
Joined: Fri Oct 14 2005
Location: Montreal
Contact:

Re: Creating Bookmarks

Post by Devteam » Mon Jul 05 2010

The printer DC should be provided by Powerbuilder and not created through CDICreateDC. Whether the code will work or not depends on whether PB gives you access to it internal printer device context, something like:
printerDC = GetPrinterDC( Job )
Amyuni Development Team

Efficient and accurate conversion to PDF, XPS, PDF/A and more. Free trials at - http://www.amyuni.com

Post Reply