I don't know why I get no printer selected when call PrintSetup(). Let me give you the scenario where it fails when I don't see any printer highlighted in PrintSetup().
We have system configuration maintenance program where we set the printer by the PSR file (Each PSR file belongs to some process like part_invoice.psr file will belong to part sales order, workshop_invoice.psr for workshop invoice etc.
For few programs, we set the printer as default printer i.e <default> or <windefault>
For few programs we set the printer as <Selectable> means it will open printer select dialog box when give print command.
We store these configuration setting into config table.
Our programs have facility to print and archive the document (We have check box for those options). For archive, we have Amyuni PDF driver which print/save as file into PDF. Here are the steps we follow during Print and Archive.
String lb_printdlg = TRUE // Always display print dialog
1 Look into Configuration table and look what is the printer option
2 If <Selectable> Then
Set Dw_Obj.Modify("Datawindow.Printer=''");
lb_printdlg = TRUE //Open dialog box.
ElseIf <default> Then
lb_printdlg = FALSE //Don't open dialog box.
Else
Call Windows Printer from Registry based on OS Type
Case Windows
RegistryGet('HKEY_LOCAL_MACHINE\Config\0001\System\CurrentControlSet\Control\Print\Printers', 'default', ls_winprinter)
Case WindowsNT
RegistryGet('HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows', 'Device', ls_winprinter)
Call ls_currentPrinter = PrintGetPrinter()
If ls_currentPrinter <> ls_winprinter //Windowsdefault printer is not same as PrintGetPrinter()
Dw_Obj.Object.DataWindow.Printer=''
PrintSetPrinter(ls_WinPrinter) //Set Windows Default Printer as printer.....
lb_printdlg = FALSE//Don't Open dialog box.
3. Dw_Obj.Print(True, lb_printdlg ) //lb_printdlg will determine whether to open the dialogbox or not.
4. PrintSetPrinter(ls_currentprinter) //Restore the printer changed in <WinDefault> condition...
For Archive
ls_printer = PrintGetPrinter() //Store current printer
PrintSetPrinter("Amyuni Printer")
Dw_Obj.saveAs(); // Overwrite SaveAs() and call Amyuni API.
PrintSetPrinter(ls_printer) //Restore printer...... Here we have issue as ls_printer is coming as blank when we don't see any printer highlighted in PrintSetup() dialog box.
Kindly advice.
Does the issue exist in PB 2017 R3 1858? As I replied to you in ticket 6261, have you tried to test your application in PB 2019 R3 2703? We need you to confirm whether it is also resolved in PB 2019 R3 because we can’t reproduce it on our side.
For this issue, have you checked whether the return value of the PrintSetPrinter function is 1? Due to that we can’t duplicate it locally, could you please try to add Yield() before the PrintSetPrinter method and see if there are any differences.
BTW, if you could provide a reproducible sample test case (including PBT/PBL) to us, please submit a ticket to our ticket system https://www.appeon.com/standardsupport/newbug with this test case so it can be properly received and tracked. Thanks in advance.
Regards,