How to print to PDF using an integration Follow

Avatar

BarTender Content Team


Question

Can you print to BarTender's native PDF printer using an integration?

Applicable to 

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

  1. Click the Print Document action in the actions list
  2. If in 2021 or later, click the Print Options tab.
  3. Check the Printer box and select [Advanced Printer Options...]

print2pdf.png

  1. In the dialog which pops up, select the second option "Generate file name"
  2. Choose where you would like to save the file

print2pdf2.png

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.

  1. Once you have chosen all your settings, click OK to close the text box and save your PDF settings.
  2. 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
%END%

 

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:

<PrintSetup>

<PrintToFile>true</PrintToFile>
        <Printer>PDF</Printer>
        <PrintToFileName MakeUnique="true" SelectAtPrintTime="false">C:\Example\test.pdf</PrintToFileName>
      </PrintSetup>

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.

Additional resources

Do you have feedback or questions on this article? We encourage you to post them on our Community Forums