How to print to PDF using an integration
Can you print to BarTender's native PDF printer using an integration?
BarTender 2019 and later
Answer / Solution
Depending on the type of print action, you can set an Integration to print to the native PDF printer with a few settings or commands.
Print Document Action
- Click the Print Document action in the actions list
- If in 2021 or later, click the Print Options tab.
- Check the Printer box and select [Advanced Printer Options...]
- In the dialog which pops up, select the second option "Generate file name"
- Choose where you would like to save the file
By default, the integration will generate the file name according to the integration name, adding a new unique suffix to the file name to make it unique.
You can change how the file name is generated as you see fit, plus change the setting from "Make Unique" to "overwrite" if you simply wish to overwrite any files in this folder.
- Once you have chosen all your settings, click OK to close the text box and save your PDF settings.
- Continue creating the rest of your integration.
Print Command Script
When creating a print command script, the printer information will be contained within the header. Like when telling the script to print to a physical printer, you can set the /PRN parameter to be "PDF" for a PDF printer.
You will need an additional parameter /PRNFILE to tell it where to save the document. You can include variable names in this parameter like in the example below, which names the PDF after the integration name:
%BTW% /F="C:\example\Document1.btw" /PRN="PDF" /PRNFILE="C:\PDF\%IntegrationName%.pdf" /P
Print BTXML Action
The printer information is set in the PrintSetup tag of your BTXML. A few tags are needed to properly set up a PDF printer like the example below:
<PrintToFileName MakeUnique="true" SelectAtPrintTime="false">C:\Example\test.pdf</PrintToFileName>
These tags are all required to properly print to PDF.
The big tag to notice is the PrintToFileName. The SelectAtPrintTime must be false as integrations are not interactive and cannot show a dialog to input a file name. Additionally in this tag, you set the file name and location as well as if you'd like to add a unique suffix to the PDF if a file is already there or overwrite it.
For more information, see the PrintToFileName tag in the help file.