Salesforce

Default Printer Behavior (Magic xpa 4.x)

« Go Back

Information

 
Created BySalesforce Service User
Approval Process StatusPublished
Objective
Description

Default Printer Behavior (Magic xpa 4.x)

Objective

This Technical Note shows you how to use the operating system's default printer even if the user changed it in previous prints.

Description

When printing a report, the printer that was chosen by the end user in the print dialog box in the previous print job will be used as the default printer. Sometimes you want to ignore the last printer selected and instead use the operating system's default printer as the default printer for the reports.

Solution

To implement the behavior described above, you can draw your printer name from the registry. The key is HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows and the subkey is Device.

To draw the registry key from Magic xpa:

  1. Use the Invoke OS operation with the command: reg export "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows" c:\temp\printer.txt

    This will write the entire key to C:\temp\printer.txt file.

  2. Use the File2Blb function to get the content of the file to Magic xpa.

  3. Use string functions to get the name of the printer for use in the INIPut function.

  4. Use the INIPut function to assign the printer name to Printer1.

Reference
Attachment 
Attachment