Generating Print Channel Documents Using Watched Folder

In this part, we will generate print channel documents using the watched folder mechanism.

After creating and testing your print channel document, we need a mechanism to generate these document in batch mode or on demand. Typically, these kinds of documents are generated in batch mode and the most common mechanism is using watched folder.

When you configure a watched folder in AEM, you associate an ECMA script or java code that gets executed when a file is dropped into the watched folder. In this article, we will focus on ECMA script which will generate print channel documents and save them to the file system.

The watched folder configuration and the ECMA script are part of the assets you imported at the beginning of this tutorial

The input file that is dropped into the watched folder has the following structure. ECMA script reads the account numbers and generates print channel document for each of these accounts.

For more details on the ECMA script for generating documents, refer to this article


To generate print channel document using the watched folder mechanism, please follow the steps below:

  • Follow the steps mentioned in this document

  • Login to crx and navigate to /etc/fd/watchfolder/scripts/PrintPDF.ecma

  • Make sure the path to interactiveCommunicationsDocument is pointing to the correct document that you want to print.( Line 1)

  • Make a note of the saveLocation(Line 2).You can change it as per your needs.

  • Make sure the input parameter to the Form Data Model is bound to the Request Attribute and its binding value is set to “accountnumber”. Refer to the screenshot below.

  • Create accountnumbers.xml file with the following content

  • Drop the xml file into C:\RenderPrintChannel\input

  • Check the pdf files in the save location as specified in the ECMA script.

Next Steps

Opening agent ui on form submission