Print Document Using a Data File Integration (Video - 6:31) Follow


BarTender Content Team

Applies to: BarTender 2016 and later. 


In this example, you design an integration that prints a specified BarTender document after detecting a trigger file, where the trigger file itself contains the data that will be used to populate the document's template objects. The techniques involved are also applicable to the later examples.


A mail order company needs to print an item containing data from a sales record each time an order is packaged. The sales application generates a comma-delimited text file, and saves it in a directory that the Integration Service is monitoring. When the file is detected, the Integration Service deletes the trigger file, sends the file contents to BarTender to populate the document's template objects, and prints the document.


The following procedures describe how to set up, deploy, and verify the integration for the scenario outlined above.

Set up the data file

  1. Create the network folder where the data files will be saved. This is the folder that the Integration Service will monitor.  In this example, it will be called \\ShippingServer\NewOrders.
  2. Create a text file containing the comma-delimited data (shown below). You can use copy and paste to insert the data into the text file.
  3. BusinessName,ContactName,Position,Address1,City,State,Zip,Country,Phone1,Phone2Around the Town,Jerome Davis,Buyer,1220 Governor Sq.,Atlanta,GA,31002,USA,(706) 555-7788,(706) 555-6750
  4. Save the text file to the directory created in Step 1, \\ShippingServer\NewOrders, naming it "order.txt".

Create the BarTender document

  1. Open BarTender.
  2. From the File menu, select New to open the New Document Wizard.
  3. Select Blank Template, and then click Finish to close the New Document Wizard.
  4. From the File menu, select Print to open the Print dialog.
  5. From the Name dropdown list, select the printer you want to use, and then click Close to close the Print dialog.
  6. From the File menu, select Page Setup to open the Page Setup dialog and configure your page as needed.
  7. When you're finished configuring your page, click OK to close the Page Setup dialog.
  8. From the File menu, select Database Connection Setup to open the Database Setup Wizard.
  9. Click Text File to specify the desired database type, and click Next.
  10. On the Select File page of the wizard, click the Select File button.
  11. Browse to \\ShippingServer\NewOrders and double-click order.txt to select it.
  12. Click Next on the Select File page of the wizard.
  13. On the File Format page of the wizard, ensure that Comma is selected in the Field Separation dropdown list, and click Next.
  14. On the Field Names page of the wizard, ensure that Automatically assign sequential field names is selected, and click Finish.
  15. Click OK to close the Database Setup dialog.
  16. From the Create menu, select Text.
  17. From the Text Objects dropdown list, select Single Line.
  18. Click anywhere on the template to add the text object.
  19. Right-click the text object, and select Properties from the context menu to open the Text Properties dialog.
  20. In the left Navigation Pane, click the text object's data source.
  21. On the Data Source tab, click  at the right of the Type field to open the Change Data Source Type Wizard.
  22. From the dropdown list, select Database Field, and then click Next.
  23. From the Field Name dropdown, select Field 2 (In the text file, the second field contains the buyer's name).
  24. In the Sample Field Data field, enter "buyer name" as the sample data.
  25. Click Finish to close the wizard.
  26. Click Close to close the Text Properties dialog.
  27. If you want to include additional database fields on your template, simply return to step 16, in each case assigning a text object to the appropriate field in the database. Otherwise, continue to step 28.
  28. From the File menu, select Save to save the BarTender document under the name NewOrderAddress.btw.
  29. Move the sample database file, order.txt, out of the folder that the Integration Service will be scanning and into another folder.
  30. Close BarTender.

Create and deploy the integration file

  1. Open Integration Builder.
  2. Click Create New Integration to open the New Integration dialog.
  3. Click File and then click OK.
  4. In the File Integration pane, select Integration.
  5. In the Properties pane, enter the Name of your integration as "Each Order".
  6. From the Start Integration dropdown list, select Automatic.
  7. Under User Account, specify user credentials. See Print document using an empty file for details.
  8. In the File Integration pane, select File Detection.
  9. In the Properties pane, under Detection Options, select "Computer/Network" from the Location dropdown list.
  10. For the Folder to Scan option, type the path or browse to the folder that you want the Integration Service to monitor. In this case, specify the \\ShippingServer\NewOrders folder that you created in the Set up the data file section, above.
  11. In the File Pattern field, type "*.txt". (Do not include the quotation marks.)
  12. Scroll down to the Actions After Detection section. From the Action dropdown list, select Delete File. When the Integration Service detects the file, it automatically reads any data in the file and places it in a variable; subsequently, once it has been detected, it is no longer needed.
  13. In the File Integration pane, click Print Document. (This is the default action.)
  14. In the Properties pane under Document, click the Browse button to browse to and select the BarTender document you created earlier, NewOrderAddress.btw. Click Open.
  15. Scroll down to Database Overrides. From the Data Source dropdown list, select Integration Input Data.
  16. Click  in the top left corner of Integration Builder to save the integration file as NewOrderAddress.btin.
  17. Click  Deploy Integration to open the New Deployment dialog.
  18. Enter a name and description for the deployment.
  19. Ensure that the Integration File setting lists NewOrderAddress.btin. Otherwise, click Browse and browse to and select NewOrderAddress.btin.
  20. For Target Servers, add the server(s) you want to deploy the integration file to.
  21. For Schedule, select Immediately.
  22. Specify the desired Error Handling settings.
  23. Click OK to close the dialog and deploy the integration file.
  24. Administration Console will open on the Integrations node, displaying your integration.

Run the scenario and view integration processing

  1. In Administration Console, click the integration name "Each Order" to open a detailed view of the integration.
  2. As you run the example scenario in the next step, you can observe the processing steps of the integration in the Output section of this view.
  3. Using Windows Explorer, copy the text file order.txt to the folder \\ShippingServer\NewOrders.
  4. The integration begins almost immediately, deleting the text file from the NewOrders folder and sending the BarTender document to print.

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