In the designer under page setup, you will see a new option under the template tab for “Printer filter”. You need to create a variable called printer which you can do by simply typing this here:
If the database field contains the actual printer name like below:
Then you can map this variable directly to the database field:
But if the database field contains some value that you want to use to control the destination printer, such as Printer A or Printer B, then you will need to map the variable to a script.
First select the functions tab and enter a script like the one below:
def selectprinter(destination):
i = destination
if i == 'A':
return 'Microsoft XPS Document Writer'
elif i == 'B':
return 'Microsoft Print to PDF'
else:
return 'Default'
You will need to replace the printer names with the real printer names as shown under Windows.
Once done it should look like this:
You will need to create a variable called destination to go along with the one called printer that you created already:
This should be mapped to the database field that contains the value used to calculate the printer name:
And then you need to change the printer variable to point to the script instead of the database field:
selectprinter(destination)
Please avoid using the word printer in any other variable names or in the script as it can cause issues.
Now the printer should be selected based on the database field.
Note: When using the Printer filter, if no matching printer is found, the default Windows printer will be used.