Print Document Using a Data File Integration (Video - 6:31)
Overview
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.
Scenario
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.
Implementation
The following procedures describe how to set up, deploy, and verify the integration for the scenario outlined above.
Set up the data file
- 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.
- 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.
-
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
- Save the text file to the directory created in Step 1, \\ShippingServer\NewOrders, naming it "order.txt".
Create the BarTender document
- Open BarTender.
- From the File menu, select New to open the New Document Wizard.
- Select Blank Template, and then click Finish to close the New Document Wizard.
- From the File menu, select Print to open the Print dialog.
- From the Name dropdown list, select the printer you want to use, and then click Close to close the Print dialog.
- From the File menu, select Page Setup to open the Page Setup dialog and configure your page as needed.
- When you're finished configuring your page, click OK to close the Page Setup dialog.
- From the File menu, select Database Connection Setup to open the Database Setup Wizard.
- Click Text File to specify the desired database type, and click Next.
- On the Select File page of the wizard, click the Select File button.
- Browse to
\\ShippingServer\NewOrders
and double-click order.txt to select it. - Click Next on the Select File page of the wizard.
- On the File Format page of the wizard, ensure that Comma is selected in the Field Separation dropdown list, and click Next.
- On the Field Names page of the wizard, ensure that Automatically assign sequential field names is selected, and click Finish.
- Click OK to close the Database Setup dialog.
- From the Create menu, select Text.
- From the Text Objects dropdown list, select Single Line.
- Click anywhere on the template to add the text object.
- Right-click the text object, and select Properties from the context menu to open the Text Properties dialog.
- In the left Navigation Pane, click the text object's data source.
- On the Data Source tab, click at the right of the Type field to open the Change Data Source Type Wizard.
- From the dropdown list, select Database Field, and then click Next.
- From the Field Name dropdown, select Field 2 (In the text file, the second field contains the buyer's name).
- In the Sample Field Data field, enter "buyer name" as the sample data.
- Click Finish to close the wizard.
- Click Close to close the Text Properties dialog.
- 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.
- From the File menu, select Save to save the BarTender document under the name NewOrderAddress.btw.
- Move the sample database file, order.txt, out of the folder that the Integration Service will be scanning and into another folder.
- Close BarTender.
Create and deploy the integration file
- Open Integration Builder.
- Click Create New Integration to open the New Integration dialog.
- Click File and then click OK.
- In the File Integration pane, select Integration.
- In the Properties pane, enter the Name of your integration as "Each Order".
- From the Start Integration dropdown list, select Automatic.
- Under User Account, specify user credentials. See Print document using an empty file for details.
- In the File Integration pane, select File Detection.
- In the Properties pane, under Detection Options, select "Computer/Network" from the Location dropdown list.
- 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.
- In the File Pattern field, type "*.txt". (Do not include the quotation marks.)
- 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.
- In the File Integration pane, click Print Document. (This is the default action.)
- 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.
- Scroll down to Database Overrides. From the Data Source dropdown list, select Integration Input Data.
- Click in the top left corner of Integration Builder to save the integration file as NewOrderAddress.btin.
- Click Deploy Integration to open the New Deployment dialog.
- Enter a name and description for the deployment.
- Ensure that the Integration File setting lists NewOrderAddress.btin. Otherwise, click Browse and browse to and select NewOrderAddress.btin.
- For Target Servers, add the server(s) you want to deploy the integration file to.
- For Schedule, select Immediately.
- Specify the desired Error Handling settings.
- Click OK to close the dialog and deploy the integration file.
- Administration Console will open on the Integrations node, displaying your integration.
Run the scenario and view integration processing
- In Administration Console, click the integration name "Each Order" to open a detailed view of the integration.
- 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.
- Using Windows Explorer, copy the text file order.txt to the folder
\\ShippingServer\NewOrders
. - The integration begins almost immediately, deleting the text file from the NewOrders folder and sending the BarTender document to print.