Problem printing with PB9 when there is a visible dw

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
swati
Posts: 6
Joined: Mon Apr 18 2005

Problem printing with PB9 when there is a visible dw

Post by swati » Fri Apr 22 2005

I have 2 scenarios in my application. In the first scenario, I have a datastore (i.e. non visible report). Once retrieved, it immediately prints to PDF, and there is NO PROBLEM with the code.

In the second scenario, I have a datawindow in preview mode. AFter the user okays it, he can click to save to PDF, USING THE SAME CODE in the first scenario. When he does this, it doesn't save to pdf. Instead, it prints to the default printer on his computer.

The only difference that I can see in the 2 scenarios, is that the first report is invisible, and the second report is visible.

Is this the problem? How can this be fixed?

Here is my code (straight from the manual)

LL_PRINT = PDFDriverInit(is_pdf_printer)
ls_printer = is_pdf_printer
SetResolution (LL_PRINT, 600)
SetDefaultConfig (LL_PRINT) // set 600 DPI as default for all printouts
ll_test = SetDefaultFileName (LL_PRINT, as_file )
ll_test = SetFileNameOptions (LL_PRINT, NoPrompt + UseFileName)
EnablePrinter( ll_print, ics_license_user, ics_license_key )
ll_test = PrintSetPrinter(is_pdf_printer)
ad_dw.print()
SetFileNameOptions (LL_PRINT, 0)
DriverEnd (LL_PRINT)
lnvo_PowerPrn.of_setdefaultprinter( ls_default )

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

Post by Joan » Mon Apr 25 2005

Hello,

Are you printing the same report in both scenarios?

Please move the call to EnablePrinter one step down in your code, call EnablePrinter right before: ad_dw.print()


Regards,

swati
Posts: 6
Joined: Mon Apr 18 2005

Post by swati » Mon Apr 25 2005

Yes, it is the same report each time. I tried moving the EnablePrinter where you indicated, but it only worked sometimes.

It seems that if I first print to a regular PRINTER in the application, then I can no longer use the pdf functionality for the visual dws. If I don't ever print, and then run the pdf functionality, I get a PDF successfully. It almost seems like Windows or PB gets a 'handle' to the printer when a regular print is issued, and then when it's time to do a pdf, it uses this handle and doesn't let another one interfere? (That is just a guess.)

Please let me know if I should try anything else, or if there is some way to get around this flakiness.

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

Post by Joan » Tue Apr 26 2005

Hello,

Printing in Powerbuilder differes slightly depending on the version of Powerbuilder you are using.

If you are using PrintSetPrinter than I assume you have version 8 or 9 of Powerbuilder.

You can set the printer of the specific datawindow to be the PDF Printer in this case this datawindow will always be printed to the PDF Printer.

Post Reply