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.
Problem printing to PDF Printer Driver from PowerBilder
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)
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)