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
Posts: 1
Joined: Wed Dec 28 2005

Creating Bookmarks

Post by Eric » Wed Dec 28 2005

I've just been assigned a project using the PDF convert and one of the requirements is concating files and creating bookmarks. I've reviewed the VB code below and have a question as to how or what the 'Printer' is defined.

I'm using version:
Amyuni PDF Converter
Version 2.06
Version 2.06 Professional

VB sample for inserting bookmarks
Public pdf As New CDIntf.CDIntf
Private Sub Form_Load()

' initialize PDF printer and set it as default
pdf.DriverInit "Amyuni PDF Converter"
pdf.SetDefaultPrinter
' draw some text
Printer.CurrentX = 200
Printer.CurrentY = 400
Printer.Print "Bookmark 1"
' set a bookmark on page 1
pdf.SetBookmark Printer.hDC, 0, "Bookmark 1"
' go to next page
Printer.NewPage

Thanks

Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan » Mon Jan 02 2006

Hello,

Printer is the Printer object of Windows, this is not related to CDIntf.

In VB you do not need to declare the Printer object, it is declared by default in any new project, you can just use it using the 'Printer' word.

In the below code, instead of printing a Word or Excel document or a report to the PDF Printer we are printing directly using the Printer object.

Hope this helps.

eric.glenn
Posts: 11
Joined: Tue Sep 02 2008

Re: Creating Bookmarks

Post by eric.glenn » Fri Nov 20 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.

Post Reply