Trouble with RestoreDefaultPrinter/DriverEnd in Citrix

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
orjaneil
Posts: 5
Joined: Mon Nov 24 2003

Trouble with RestoreDefaultPrinter/DriverEnd in Citrix

Post by orjaneil »

Hi!

I have trouble i Citrix with restoring to the printer driver used before printing to pdf. The default printer seems to be stuck at the pdf printer driver.

I have this code to print to pdf:

If GetFileSaveName('PDF filename',ls_pathNfilename,ls_filename) = 1 Then
ls_printer = "Amyuni PDF Converter"
ll_pdfPrinter = DriverInit(ls_printer)

If ll_pdfPrinter <> 0 Then
SetResolution(ll_pdfPrinter, 600)
SetDefaultConfig(ll_pdfPrinter)
SetDefaultPrinter(ll_pdfPrinter)
SetDefaultFileName(ll_pdfPrinter, ls_pathNfilename)
SetFileNameOptions (ll_pdfPrinter, NoPrompt + UseFileName)
EnablePrinter(ll_pdfPrinter,LicensedTo,ActivationCode)
PrintSetPrinter(ls_printer)
dw_1.print()

SetFileNameOptions(ll_pdfPrinter, 0)
RestoreDefaultPrinter(ll_pdfPrinter) // Is this in the DriverEnd too?
DriverEnd(ll_pdfPrinter)
End if
End if

I thought that the RestoreDefaultPrinter was able to set back to another printer, but the printer is stuck on the pdf printer driver.

I hope someone can help me ASAP with this issue.

TIA

Ørjan Eilertsen
System Developer
Jose
Amyuni Team
Posts: 553
Joined: Tue Oct 01 2002
Contact:

Post by Jose »

Hello,

Hello,

Instead of modifying the system’s default printer, I suggest that you set the PDF Converter as the datawindow printer.

Example:
dw_datawidow1.Modify('DataWindow.Printer="Amyuni PDF Converter" ')

If you are using PowerBuilder 8, than SetDefaultPrinter will not work correctly and you should use the PrintSetPrinter() instead.


Below is a pseudocode snippet:

string defaultPrinter
defaultPrinter = PrintGetPrinter() // get the default printer of the system

DriverInit("Amyuni PDF Converter")
PrintSetPrinter("Amyuni PDF Converter")
// Printing goes here
.....
DriverEnd
PrintSetPrinter(defaultPrinter) // restore the default printer of the system.

Hope this helps?
Post Reply