Problem printing to PDF Printer Driver from PowerBilder

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
Vladb
Posts: 2
Joined: Thu Aug 05 2004

Problem printing to PDF Printer Driver from PowerBilder

Post by Vladb »

Hello,

I am not able to generate a pdf file printing to PDF Printer Driver. I am using PowerBilder 9. I created a test form, put an external data window (with a couple of rows) and a button on it. In the click event of the button I put a piece of code I took from Technical Note 6.pdf(with some cosmetical changes). Here is the code:

long ll_rc
PDFPrinter = PdfDriverInit("My PDF Export")
ll_rc = SetResolution (PDFPrinter, 600)
ll_rc = SetDefaultConfig (PDFPrinter)
ll_rc = SetDefaultPrinter (PDFPrinter)
ll_rc = SetDefaultFileName (PDFPrinter, OutputFile)
ll_rc = SetFileNameOptions (PDFPrinter, 3)
ll_rc = EnablePrinter(pdfPrinter,LicensedTo,ActivationCode)
ll_rc = dw_1.print()
ll_rc = SetFileNameOptions (PDFPrinter, 0)
DriverEnd (PDFPrinter)

ll_rc always returns 1.
As a result the data window is printed on one of my network printers (the one that is selected as the default one in windows). I can see new printer being created and set as default if I debug the program, but it seems to ignore that and send the output to the previous default printer.
I have PowerBuilder 9, Windows XP. LicensedTo and ActivationCode are taken from the install.ini file in the program's directory. I have a Developer Demo version of Amyuni PDF converter 2.1.
Could anyone give me a hint why this is happening?

Thank you,

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

Post by Joan »

Hello,

I replied to you by e-mail.

When you adjust your code please post the new version here.

I will move this thread to the PowerBuilder community.
Vladb
Posts: 2
Joined: Thu Aug 05 2004

Post by Vladb »

Thanks Joan,

I changed the code as you said and it worked.
Here it is:

long ll_rc
PDFPrinter = PdfDriverInit("My PDF Export")
ll_rc = SetResolution (PDFPrinter, 600)
ll_rc = SetDefaultConfig (PDFPrinter)
//ll_rc = SetDefaultPrinter (PDFPrinter)
ll_rc = SetDefaultFileName (PDFPrinter, OutputFile)
ll_rc = SetFileNameOptions (PDFPrinter, 3)
ll_rc = EnablePrinter(pdfPrinter,LicensedTo,ActivationCode)
// SetDefaultPrinter can be replaced with this
PrintSetPrinter("My PDF Export")
// or this dw_1.Modify('DataWindow.Printer = "My PDF Export"')
ll_rc = dw_1.print()
ll_rc = SetFileNameOptions (PDFPrinter, 0)
DriverEnd (PDFPrinter)
Post Reply