Generating output

When merged with a record set, the templates made in the Designer can generate three types of output: Print, Email and Web.

Print output

Print templates, also called Print sections, are part of the Print context. They are meant to be printed to a printer or printer stream, or to a PDF file (see Generating Print output).
The Print context can also be added to Email output as a PDF attachment; see Generating Email output. When generating output from the Print context, each of the Print sections is added to the output document, one after the other in sequence, for each record.

To dynamically select a section for output, use a Control Script; see Control Scripts.

There is a number of settings in the Print context and Print sections that have an impact on how the Print context is printed; see Print settings in the Print context and sections.

To split the Print output into several files, see Splitting printing into more than one file.

Email output

The Email context outputs HTML email with embedded formatting to an email client through the use of an email server. The HTML generated by this context is meant to be compatible with as many clients and as many devices as possible.

Although the Email context can contain multiple Email templates, only one of them can be merged with each record. Which one is used, depends on a setting; see Email output settings in the Email context and sections.

Email Output can be generated in two different ways: from the Designer or via Workflow. In both cases, email is sent in a single batch for the whole record set.

To test a template, you can test the scripts (see Testing scripts) and send a test email first (see Send Test Email), before actually sending the email (see Generating Email output).

Attachments

Output, generated from an Email template, can have the following attachments:

  • The contents of the Print context, in the form of a single PDF attachment.
  • The output of the Web context, as an integral HTML file.
  • Other files, an image or a PDF leaflet for example.
  • Attaching the Print context and/or the Web context is one of the options in the Send (Test) Email dialog.
  • To learn how to attach other files, see Email attachments.

    Web output

    The Web context outputs an HTML web page that contains the HTML text and all the resources necessary to display it.

    Web output can be generated in two different ways: it can be attached to an Email template when generating Email output (see above), or it can be generated using Workflow; see Generating Web output.

    Although the Web context can contain multiple Web pages, only one of them can be merged with each record. Which one is used, depends on a setting; see Web output settings in the Web context and sections.

    Optimizing a template

    Scripts

    In the process of output generation, the execution of scripts may take up more time than necessary. To optimize a template, it helps to disable scripts that don't have an effect on the context that you're generating output from; see Managing scripts.

    Other ways to speed up script execution are described in another topic: Optimizing scripts.

    Images

    When a template that contains lots of images is merged with a large record set, the many file requests may slow down the process of output generation. The solution is simple: combine the images into a single image file and display the part that holds the image. This reduces the number of file requests and can improve the output speed significantly.

    Step 1. Create a file that contains a collection of images.

    Static images may go in any type of image file. Store images that need be added dynamically to the template, in one PDF file, one image per page.

    There are several tools to combine image files into a singe PDF. ImageMagick is one of them. You could use the convert command of the ImageMagick library:

    convert C:/myimages/*.jpg C:/myimages/image-collection.pdf

    You could also use Connect Designer itself: create a print template with the size of your images and set the page margins to 0. Create a script that loops over your images and adds them to the text flow of the template. Subsequently generate PDF output and use the resulting file as your collection file.

    Step 2. Add the file that contains the collection of images to the template's Resources (see Adding images).
    Step 3. Display part of the collection file as an image in the template.
    • Static images that are part of an image file can be displayed via Cascading Style Sheets (CSS). This technique is much used in web design. In this technique, the file that contains a collection of images is called an image sprite. The trick is to create a Box (or Div) for each image and give that box an ID (see Boxes). Then use the ID in a style sheet to select the Box and write a style rule (see Styling templates with CSS files) that sets its background image to the image sprite and positions the image.

      For an explanation and examples of this style rule, see http://www.w3schools.com/css/css_image_sprites.asp.

    • Dynamically added images are loaded in a script. To retrieve one page from a PDF file in a script, add the page parameter to the file path and set that as the source of the image. Here is an example (assuming that the page number is stored in a variable pageNumber):

      var imageStr = "";
      var imagePath = "file:///C:/image-collection.pdf?page=" + pageNumber;
      imageStr += '<img src="' + imagePath + '">';
      results.after(imageStr);
     
    • Last Topic Update: 24/01/2017 09:32
    • Last Published: 7/6/2017 : 9:49 AM