1.4
- Table of Contents
- Welcome to PrintShop Mail Connect 1.4.2
- Setup And Configuration
- The Designer
- Mark Position Options
- Additional Text Settings
- Additional Image Settings
- Barcode Options
- Codabar Settings
- Code 128 Settings
- Code 39 Settings
- Additional Datamatrix Settings
- Additional EAN 128 Settings
- Additional EAN 13 Settings
- Additional EAN 8 Settings
- Additional Interleave 2 of 5 Settings
- Additional PDF417 Settings
- Additional QR Code Settings
- Additional UPC A Settings
- Additional UPC E Settings
- Additional OMR Mark Settings
- Keystore
- PDF Signature
- Print Manager
- Copyright Information
- Legal Notices and Acknowledgements
Summary of content (414 pages)
Personal information
Name: Peter Parker
This script inserts content in multiplePAGE 58
Matched element Matched element after script execution
Peter Parker
Personal information
Peter Parker
Personal information
").PAGE 59
query(selector) Creates a new result set containing the HTML elements in the template that match the supplied CSS selector. selector A String containing a CSS selector. See http://www.w3schools.com/cssref/css_selectors.asp for CSS selectors and combinations of CSS selectors. query(selector, context) Creates a new result set containing the HTML elements that match the supplied CSS selector. The context (optional) allows you to restrict the search to descendants of one or more context elements.
PAGE 60
CopyFile() Examples removeClass() Removes the specified class from each element in this result set. Has no effect if the class is not present. removeClass(classname) classname String, space separated list of class names. Examples This script removes the class name "foo" from all elements in the results that have this class. results.
PAGE 61
Examples Replace elements with a snippet The following script loads a snippet and then replaces the elements matched by the script's selector with the snippet. var snippet = loadhtml('snippets/mysnippet.html'); results.replaceWith(snippet); Replace elements with a set of snippets The following script loads snippets and adds their elements to a new, empty result set (using query()). Then it replaces a placeholder in the template with the set of snippets.
PAGE 62
ContextType This is an enumeration for the context types. Value Description HTML_EMAIL The context is the Email context PRINT The context is the Print context WEB The context is the Web context Merge The root level instance of the object merge is the entry point in Control Scripts for the objects and references required to query and modify various aspects. Field Type Description context Context The context rendered by this merge pass.
PAGE 63
sections Array Array of sections inside this context defined in the template. type ContextType The context type. Template Template is an object representing the template. Which contexts are available in the template can be queried using merge.template.contexts. The context being merged can be queried using merge.context. Field Type Description contexts Array Array of contexts available in the template. Section A section object relating to a section in the template.
PAGE 64
email. For Email channel requests on the Print context all Print sections are enabled by default. It is possible to enable different or multiple sections to control which sections will be attached to the email. For Print channel requests on the Print context all sections are enabled by default. name [READONLY] String The name of the section as shown in the resources view. Note that sections cannot have an integer as name. The name should always include alphanumeric characters.
PAGE 65
PDF can be the PDF file that was used as input file, or another type of input file, converted to PDF. Note From DataMapper input cannot be used in PrintShopMail Connect. The DataMapper is included only in PlanetPress Connect and PreS Connect. NONE No PDF background. RESOURCE_ PDF A PDF file stored in the template or on the network. Note that it isn't possible to use a remotely stored PDF file as a section's background.
PAGE 66
l When using merge.context.sections keep in mind that for example 'Section X' might only exist in your Print context, so using merge.context.sections ['Section X'] without enclosing it in the if statement if (merge.context.type == ContextType.PRINT) {} will yield an error when the script runs for other contexts. Instead of enclosing it in an if statement, you can use the template object to access a specific context: merge.template.contexts.PRINT.sections['Section X'] .
PAGE 67
l l l Print section 3 + 4 as attachment with continued page numbers Print section 6 as separate attachment Web sections A and B as separate attachment if (channel == Channel.EMAIL) { // only when generating Email output if (merge.context.type == ContextType.PRINT) { merge.context.sections['Section 1'].enabled = false; merge.context.sections['Section 2'].enabled = false; merge.context.sections['Section 3'].enabled = true; merge.context.sections['Section 3'].part = "PDFAttach1"; merge.context.
PAGE 68
// Specify the path var resourceUrl = 'images/policy-' + record.fields.policy + '.pdf'; merge.template.contexts.PRINT.sections['Policy'].background.url = resourceUrl; Positioning the background of a Print section Using abolute positioning var activeSection = merge.template.contexts.PRINT.sections['Section 1']; activeSection.background.source = BackgroundResource.RESOURCE_PDF; activeSection.background.position = MediaPosition.ABSOLUTE; activeSection.background.left = "10mm"; activeSection.background.
PAGE 69
4. Generate output Adjust the settings, test the template and generate output: letters and emails. See Skin/Formats/CrossReferencePrintFormat("Generating outputWhen merged with a record set, the templates made in the Designer can generate twotypes of output: Print, and Email.Print outputPrint 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 Generate Print output).
PAGE 70
"Content elements" on page 72. Elements make up the biggest part of the content of each design. "Email" on page 127. Email is one of the intended output channels. This topics helps you design an email template. Skin/Formats/CrossReferencePrintFormat("Generating outputWhen merged with a record set, the templates made in the Designer can generate twotypes of output: Print, and Email.Print outputPrint templates, also called Print sections, are part of the Print context.
PAGE 71
"Styling and formatting" on page 217. Make your Designer templates look pretty and give them the same look and feel with style sheets. "Templates" on page 243. Start creating, using and sharing templates. Web. Web is one of the intended output channels. This topic helps you design a web page. "Write your own scripts" on page 195. Scripting can take personalization much further. Learn how to script via this topic.
PAGE 72
If present in the same template, a Print context and a Web context can be attached to an Email context. Outputting other combinations of contexts, and selecting sections based on a value in the data, can be done via a Control Script; see "Control Scripts" on page 208. Adding a context To add a context, right-click the Contexts folder on the Resources pane and click New print context, New email context or New web context. Only one context of each type can be present in a template.
PAGE 73
When you add elements, such as text, images or a table, to the content of a template, you are actually constructing an HTML file. It is possible to edit the source of the HTML file directly in the Designer; see "Editing HTML" on the facing page.
PAGE 74
Whether it is best to use a Table or Box to position text, images and other elements, depends on the context in which they are used; see "How to position elements" on page 230 for more information. Editing HTML When you add elements, such as text, images or a table, to the content of a template, you are actually constructing an HTML file. To see this, toggle to the Design tab in the workspace. Click anywhere in the content. Take a look at the breadcrumbs at the top of the workspace.
PAGE 75
To add an ID and/or class to an element that has already been added to a template, select the element (see "Selecting an element" on the facing page) and type an ID and/or a class in the respective fields on the Attributes pane at the top right. Other attributes Apart from the ID and class, elements can have a varying number of properties, or 'attributes' as they're called in HTML (see "Editing HTML" on the previous page). Which properties an element has, depends on the element itself.
PAGE 76
l l l l Before element: The element is inserted before the current HTML element where the cursor is located. For example if the cursor is within a paragraph, insertion occurs before the
tag.* After start tag: The element is inserted within the current HTML element, at the beginning, just after the start tag.* Before end tag: The element is inserted within the current HTML element, at the end, just before the end tag.
PAGE 77
l element is at the end of the line. Elements with classes or IDs show these details next to them, for instance div #contents > ol.salesitems > li. Click any of the elements in the Breadcrumbs to select that element. If an element is selected in the Breadcrumbs and the Backspace key is pressed, that element is deleted. Use the Outline pane. You can find this pane next to the Resources pane. It displays a tree view of the elements in the file. Click an element in the tree view to select it.
PAGE 78
horizontally and vertically). Adding a Barcode Note When generating Print output, you can add extra barcodes and OMR marks. The reason why you would do this, is that at merge time more information is available about the actual output document. The page count, for example, is not available at design time. To add barcodes and OMR marks on the fly when generating Print output, select File > Print and check the option Add additional content (see "Additional Text" on page 340) in the Print Wizard.
PAGE 79
* If the current element is located inside another element, use the Elements drop-down to select which element is used for the insertion location. The list displays every element in the breadcrumbs, from the current selection point until the root of the body. 5. Under Script, select the field that contains the barcode value, or select the fields that together compose the barcode value.
PAGE 80
l l l l l l l l l l l l l l l "Code 39, Code 39 extended" on page 86 "UPC-A, UPC-E, EAN-8, EAN-13" on page 112 "OneCode, KIX Code, Royal Mail, Australia Post" on page 110 "Code 128" on page 89 "GS1-128" on page 94 "Codabar" on page 83 "MSI" on page 102 "IMPB" on page 96 "Postnet" on page 106 "QR Code" on page 108 "Data Matrix" on page 90 "Royal Mail Mailmark" on page 111 "PDF417" on page 105 "Aztec Code" on the next page "MaxiCode" on page 101 Tip As of version 1.
PAGE 81
l l l l Bar height: the height of the (shorter) bars Extended bar height: the total height of the extended bars Bar width: the width of the bars Spacing: the distance between the bars Scale Defines if and how the rendered barcode is scaled in relation to the parent element: l l l None: The barcode is rendered based on the module width. Fit to box: The barcode is stretched to fit the parent box in both width and height.
PAGE 82
Barcode properties This topic lists the properties of the barcode type Aztec. For the properties of other barcode types, see "Barcode properties" on page 79. Module size Enter the size of the square modules in pixels Configuration type Use the drop-down to select the format type used when creating the barcode: only full range format, only compact formats, or any format. Preferred configuration Use the drop-down to select the preferred format for the barcode.
PAGE 83
l Proportionally: The barcode is stretched up to where it fits either the width or height of the parent box, whichever requires the less stretching. Color The Color property allows you to choose a different Barcode color (instead of black) and Background color (instead of white), by typing a hexadecimal color value (see for example w3school's color picker). Output format Defines how the barcode is output on the page. There are two possible formats: l l SVG: Vector format.
PAGE 84
Scale Defines if and how the rendered barcode is scaled in relation to the parent element: l l l None: The barcode is rendered based on the module width. Fit to box: The barcode is stretched to fit the parent box in both width and height. Proportionally: The barcode is stretched up to where it fits either the width or height of the parent box, whichever requires the less stretching.
PAGE 85
Initially the barcode will have the barcode type's default properties. To change those properties, such as the scale and color, open the Barcode properties dialog: right-click the barcode (on the Design tab in the Workspace) and select the barcode type on the shortcut menu.
PAGE 86
Color The Color property allows you to choose a different Barcode color (instead of black) and Background color (instead of white), by typing a hexadecimal color value (see for example w3school's color picker). Output format Defines how the barcode is output on the page. There are two possible formats: l l SVG: Vector format. This is smaller in size, but not compatible with Email output. PNG: Binary rasterized format. This is slightly larger than SVG but will display properly in Email output.
PAGE 87
l l l None: The barcode is rendered based on the module width. Fit to box: The barcode is stretched to fit the parent box in both width and height. Proportionally: The barcode is stretched up to where it fits either the width or height of the parent box, whichever requires the less stretching. Add Checksum When checked, PrintShop Mail Connect will calculate a Checksum character and add that to the result of the Barcode script.
PAGE 88
Barcode properties This topic lists the properties of the following barcode types : l l l l l l Code 11 Code 93 Code 93 extended Industrial 2 of 5 Interleaved 2 of 5 Matrix 2 of 5 For the properties of other barcode types, see "Barcode properties" on page 79. Module width Specifies the width of the narrow bars in centimeters. Changing this value to a higher value will make the barcode bigger when Scale is set to None.
PAGE 89
w3school's color picker). Output format Defines how the barcode is output on the page. There are two possible formats: l l SVG: Vector format. This is smaller in size, but not compatible with Email output. PNG: Binary rasterized format. This is slightly larger than SVG but will display properly in Email output. Code 128 Code 128 is one of the types of barcodes that can be added to a template; see "Barcode" on page 77.
PAGE 90
In Auto mode, the barcode generator will automatically select the correct encoding mode (set A, B or C) according to the input data. Scale Defines if and how the rendered barcode is scaled in relation to the parent element: l l l None: The barcode is rendered based on the module width. Fit to box: The barcode is stretched to fit the parent box in both width and height.
PAGE 91
The barcode can be added either using the Barcode toolbar button or through selecting Insert > Barcode on the menu; see " Adding a Barcode" on page 78. Initially the barcode will have the barcode type's default properties. To change those properties, such as the scale and color, open the Barcode properties dialog: right-click the barcode (on the Design tab in the Workspace) and select the barcode type on the shortcut menu. Barcode properties This topic lists the properties of the QR barcode.
PAGE 92
Color The Color property allows you to choose a different Barcode color (instead of black) and Background color (instead of white), by typing a hexadecimal color value (see for example w3school's color picker). Output format Defines how the barcode is output on the page. There are two possible formats: l l SVG: Vector format. This is smaller in size, but not compatible with Email output. PNG: Binary rasterized format. This is slightly larger than SVG but will display properly in Email output.
PAGE 93
l l l None: The barcode is rendered based on the module width. Fit to box: The barcode is stretched to fit the parent box in both width and height. Proportionally: The barcode is stretched up to where it fits either the width or height of the parent box, whichever requires the less stretching. Supplement UPC-A, UPC-E, EAN-13, and EAN-8 may all include an additional barcode to the right of the main barcode.
PAGE 94
l l SVG: Vector format. This is smaller in size, but not compatible with Email output. PNG: Binary rasterized format. This is slightly larger than SVG but will display properly in Email output. GS1-128 GS1-128 is one of the types of barcodes that can be added to a template; see "Barcode" on page 77. The barcode can be added either using the Barcode toolbar button or through selecting Insert > Barcode on the menu; see " Adding a Barcode" on page 78.
PAGE 95
Human Readable Message When this option is checked, PrintShop Mail Connect shows a human readable text below or above the barcode, as defined using the Text Position, using the specified font and font size. The font size is given in points (pt). Color The Color property allows you to choose a different Barcode color (instead of black) and Background color (instead of white), by typing a hexadecimal color value (see for example w3school's color picker).
PAGE 96
l l Bar width: the width of the bars Spacing: the distance between the bars Scale Defines if and how the rendered barcode is scaled in relation to the parent element: l l l None: The barcode is rendered based on the module width. Fit to box: The barcode is stretched to fit the parent box in both width and height. Proportionally: The barcode is stretched up to where it fits either the width or height of the parent box, whichever requires the less stretching.
PAGE 97
Color The Color property allows you to choose a different Barcode color (instead of black) and Background color (instead of white), by typing a hexadecimal color value (see for example w3school's color picker). Output format Defines how the barcode is output on the page. There are two possible formats: l l SVG: Vector format. This is smaller in size, but not compatible with Email output. PNG: Binary rasterized format. This is slightly larger than SVG but will display properly in Email output.
PAGE 98
Scale Defines if and how the rendered barcode is scaled in relation to the parent element: l l l None: The barcode is rendered based on the module width. Fit to box: The barcode is stretched to fit the parent box in both width and height. Proportionally: The barcode is stretched up to where it fits either the width or height of the parent box, whichever requires the less stretching.
PAGE 99
Initially the barcode will have the barcode type's default properties. To change those properties, such as the scale and color, open the Barcode properties dialog: right-click the barcode (on the Design tab in the Workspace) and select the barcode type on the shortcut menu.
PAGE 100
Color The Color property allows you to choose a different Barcode color (instead of black) and Background color (instead of white), by typing a hexadecimal color value (see for example w3school's color picker). Output format Defines how the barcode is output on the page. There are two possible formats: l l SVG: Vector format. This is smaller in size, but not compatible with Email output. PNG: Binary rasterized format. This is slightly larger than SVG but will display properly in Email output.
PAGE 101
Scale Defines if and how the rendered barcode is scaled in relation to the parent element: l l l None: The barcode is rendered based on the module width. Fit to box: The barcode is stretched to fit the parent box in both width and height. Proportionally: The barcode is stretched up to where it fits either the width or height of the parent box, whichever requires the less stretching.
PAGE 102
Initially the barcode will have the barcode type's default properties. To change those properties, such as the scale and color, open the Barcode properties dialog: right-click the barcode (on the Design tab in the Workspace) and select the barcode type on the shortcut menu. Barcode properties This topic lists the properties of the MaxiCode barcode. For the properties of other barcode types, see "Barcode properties" on page 79.
PAGE 103
l l l None: The barcode is rendered based on the module width. Fit to box: The barcode is stretched to fit the parent box in both width and height. Proportionally: The barcode is stretched up to where it fits either the width or height of the parent box, whichever requires the less stretching. Add Checksum When checked, PrintShop Mail Connect will calculate a Checksum character and add that to the result of the Barcode script.
PAGE 104
Initially the barcode will have the barcode type's default properties. To change those properties, such as the scale and color, open the Barcode properties dialog: right-click the barcode (on the Design tab in the Workspace) and select the barcode type on the shortcut menu. Barcode properties This topic lists the properties of the barcode types OneCode, KIX Code, Royal Mail and Australia Post. For the properties of other barcode types, see "Barcode properties" on page 79.
PAGE 105
PDF417 PDF417 is one of the types of barcodes that can be added to a template; see "Barcode" on page 77. The barcode can be added either using the Barcode toolbar button or through selecting Insert > Barcode on the menu; see " Adding a Barcode" on page 78. Initially the barcode will have the barcode type's default properties.
PAGE 106
Bar height Defines the height of the bars for a single row measured in pixels drawn. Compact Check this option to use Compact PDF417 instead of the PDF417 barcode. This shortened form of the PDF417 barcode is useful where the space for the symbol is restricted. Scale Defines if and how the rendered barcode is scaled in relation to the parent element: l l l None: The barcode is rendered based on the module width. Fit to box: The barcode is stretched to fit the parent box in both width and height.
PAGE 107
Barcode properties This topic lists the properties of the barcode type Postnet. For the properties of other barcode types, see "Barcode properties" on page 79. Module width Specifies the width of the narrow bars in centimeters. Changing this value to a higher value will make the barcode bigger when Scale is set to None. Bar height You can set the height (in cm) of the short bars and the tall bars in the Postnet barcode.
PAGE 108
QR Code A QR Code is one of the types of barcodes that can be added to a template; see "Barcode" on page 77. The barcode can be added either using the Barcode toolbar button or through selecting Insert > Barcode on the menu; see " Adding a Barcode" on page 78. Initially the barcode will have the barcode type's default properties.
PAGE 109
Extended Channel Interpretation (ECI) This setting enables data using character sets other than the default set. Select Latin-1, Shift JIS or UTF-8, or select None to disable extended channel interpretation. Correction level Part of the robustness of QR codes in the physical environment is their ability to sustain 'damage' and continue to function even when a part of the QR code image is obscured, defaced or removed.
PAGE 110
l l SVG: Vector format. This is smaller in size, but not compatible with Email output. PNG: Binary rasterized format. This is slightly larger than SVG but will display properly in Email output. Barcode Data QR Codes can have many different types of data, which determines how the code will be generated. On top of just straightforward data, special data structures are used to trigger actions on the device that reads them. This can include contact cards, phone numbers, URLs, emails, etc.
PAGE 111
l l l None: The barcode is rendered based on the module width. Fit to box: The barcode is stretched to fit the parent box in both width and height. Proportionally: The barcode is stretched up to where it fits either the width or height of the parent box, whichever requires the less stretching. Color The Color property allows you to choose a different Barcode color (instead of black) and Background color (instead of white), by typing a hexadecimal color value (see for example w3school's color picker).
PAGE 112
Preferred version Use the drop-down to select the size of the barcode, in a number of modules. The actual size of the barcode can be 12 mm x 12 mm up to 22.4 mm x 22.4 mm, depending on the preferred version and the module width. Scale Defines if and how the rendered barcode is scaled in relation to the parent element: l l l None: The barcode is rendered based on the module width. Fit to box: The barcode is stretched to fit the parent box in both width and height.
PAGE 113
Barcode properties This topic lists the properties of the barcode types UPC-A, UPC-E, EAN-8 and EAN-13. For the properties of other barcode types, see "Barcode properties" on page 79. Module width Specifies the width of the narrow bars in centimeters. Changing this value to a higher value will make the barcode bigger when Scale is set to None. Show guardbars Checking this option adds guardbars to the barcode.
PAGE 114
l normal bars. Space Before : Defines the space between the main symbol and the supplement, in cm. Human Readable Message When this option is checked, PrintShop Mail Connect shows a human readable text below or above the barcode, as defined using the Text Position, using the specified font and font size. The font size is given in points (pt).
PAGE 115
Positioned Boxes are suitable for use in Print templates only. Adding a Positioned Box To insert a Positioned Box, use the icon on the toolbar. Positioned Boxes can be moved by dragging the borders, and resized using the handles on the sides and the corners. They can be styled using the Format > Box menu item, through the CTRL+M keyboard shortcut or through the CSS files; see "Styling and formatting" on page 217 and "Styling templates with CSS files" on page 219.
PAGE 116
Span The Span element ( in HTML code) is used to group inline elements, such as text in a paragraph. A Span doesn't provide any visual change by itself, but it provides a way to target its content in a script or in a style sheet. To wrap content in a span, select the text and other inline elements and click Insert > Wrap in Span on the menu.
PAGE 117
Adding a date To add a date, use the Insert > Date option in the "Menus" on page 282. A dialog appears with the following controls: l l l Language: Use the drop-down to select which language the date should be displayed in. Update Automatically: Check to update the date automatically when the template is viewed or produces output. When this option is checked, a placeholder is inserted in the template and a script is created to update it automatically, otherwise a static text with the date is inserted.
PAGE 118
Locale can be the system's locale, a specific locale, or it can depend on the value of a data field; see "Locale" on page 240. Hyperlink and mailto link Links can be added to any template but they only work in electronic output (web pages, email and PDF files). They can be a regular hyperlink pointing to a web page or a mailto link that will open the default email client when clicked.
PAGE 119
4. For a URL: URL: enter a valid, well-formed URL to link to. It must start with the protocol, such as http:// or https://. l Target: use the drop-down or type in the target for the link.When the target is _ blank the link will open in a new browser window or tab. For a mailto link: l Email: enter a valid email address that appears by default in the To: field of the email client. l Subject: type a default subject that appears in the Subject: field of the email client.
PAGE 120
Dynamic image Images can be switched dynamically, so that a letteror email can include one image or another, depending on a value in the data set. Read "Dynamic Images" on page 169 to find out how to add such switching images. Background image Several parts of templates can have a background image. See "Background color and/or image" on page 231 and "Using a PDF file as background image" on page 179. Tip To create a Print section from an existing PDF file, use a PDF file as a Print section's background.
PAGE 121
2. Browse to the file and click Open. 3. Check the option Save with template to import the image. Imported images are saved within the template file, so they are always available and don't depend on external paths, servers or URLs. If this option is checked, the image file will be inserted in the Images folder on the Resources pane at the top left. Uncheck this option if the image should be used as an external image (see also: "Using external images" below). 4. Click Finish.
PAGE 122
4. Enter an alternate text. This text will be shown in emails at the position of the image while the image is loading and when the image is not found. 5. Click Finish. The image will be inserted at the current position of the cursor in the template. For information about referring to images in HTML or in a script, see "Resources" on page 253. Styling an image Images can be styled using the Format > Image menu item. They have a border, margin and padding; see "Border" on page 233 and "Spacing" on page 241.
PAGE 123
Rotating an image To rotate an image, select the image (see "Selecting an element" on page 76) and select Format > Image, on the menu. On the Image tab, set the rotation angle of the image in clockwise degrees. This is equivalent to the transform:rotate property in CSS. Setting an alternate text Once an image has been inserted in the content of a template, it can have an alternate text.
PAGE 124
Inserting a Table 1. On the toolbar, click the Insert table button, or on the menu select Insert > Table > Standard. 2. Enter the table's desired attributes: l l l l l ID: a unique identifier for the table. IDs are used to access the Table from scripts and as CSS selectors for style rules. Class: A class identifier for the table. Classes can be shared between elements and are used to access the table from scripts and as CSS selectors for style rules.
PAGE 125
determined in the Source mode or in a style sheet. 7. Click Finish to add the table to the section. Header and footer Adding a header or footer To add a header or footer to an existing table, right-click the table and then select Table > Insert thead or Insert tfoot, on the shortcut menu. Alternatively, click in one of the cells and select Insert > Table > Insert thead or Insert tfoot, on the menu.
PAGE 126
Text and special characters The vast majority of templates for personalized customer communications contain, of course, text. While the most common text element is a
or paragraph, other elements such as Headings (
through ) are also considered text elements. Text elements can be present within other types of elements such as table cells (), boxes (), etc. Adding text To add text, simply type in the workspace in the middle. l l Press Enter to insert a new paragraph.
PAGE 127
In HTML text can be contained in many different elements: paragraphs, span elements, line items and table cells, for example. The HTML tag of a paragraph is
. The paragraph should be followed by a closing tag:
. A line break looks like this in HTML:
. Formatting text Text can be styled, colored, centered, indented etc. It can even be displayed so that it reads from right to left. See "Styling text and paragraphs" on page 226.
PAGE 128
Email templates are personalized just like any other template; see "Variable Data" on page 159. Sending email When the template is ready, you can change the email settings (see "Email header settings" on page 133) and send the email. To test a template, you can send a test email first.
PAGE 129
Sending email When the template is ready, you can generate Email output; See "Generating Email output" on page 148. To test a template, you can send a test email first. Email output can have the following attachments: l l l The contents of the Print context, in the form of one PDF attachment. The default section of the Web context, as an integral HTML file. Other files.
PAGE 130
decompressed. When low Quality values are used to optimize images smaller than 1024 x 1024 pixels, using the largest tile size will produce better results. Setting a default section for output When generating output from the Email context, only one of the Email templates can be merged with each record. One of the Email sections is the 'default'; see "Setting a default Email template for output" on page 132.
PAGE 131
To provide alternative content for your email, you could use Conditional Content (see "Showing content conditionally" on page 167), or Snippets and a script (see "Snippets" on page 216 and "Loading a snippet via a script" on page 205). If you would like to start with a template that is identical to the one you already have, consider copying it (see "Copying a section" on page 212).
PAGE 132
Tip Before you can style an element, you have to select it. In an Email context it can be difficult to select an element by clicking on it. Use the breadcrumbs at the top and the Outline pane at the left, to select an element. See "Selecting an element" on page 76. In order for a style sheet to be applied to a specific section, it needs to be included in that section. There are two ways to do this. Drag & drop a style sheet 1. Click and hold the mouse button on the style sheet on the Resources pane. 2.
PAGE 133
value of a data field. Email header settings Email header settings define the information that goes into the header of each email that is generated from an Email template. The default Email SMTP settings and the sender's name and address are defined in the preferences and can be adjusted in the Send Email and Send Test Email dialogs. The subject, the recipients (To, CC and BCC), the sender and the reply-to address can be specified with Email Script Wizards.
PAGE 134
In the Send Email and Send Test Email dialogs you will be able to choose one of the three presets and adjust the settings to your needs. Subject To specify a subject for an email template: 1. On the Resources pane, expand the Contexts folder, and expand the Email section. 2. Right-click the section of which the subject should change and click Properties. Now you can change the subject. Creating a dynamic subject with variable data To replace an Email section's subject by a dynamic subject: 1.
PAGE 135
The result of this script goes in the email's To, CC, or BCC address field, respectively. It should be a valid, fully-formed email address. Sender From address A default From name and email address can be specified in the Preferences dialog: select Window > Preferences, expand the Email preferences and click General. This name and email address will appear as the default in the Send Email and Send Test Email dialogs. To dynamically specify a From address you have to use the Email From Script Wizard: 1.
PAGE 136
To define a password to protect the generated PDF attachment: 1. On the Scripts pane, click the black triangle on the New button and click Email PDF password Script. A new script is added to the Scripts pane. 2. Double-click the new script to open it. 3. Select a data field and optionally, type a prefix and/or suffix. Email attachments Output, generated from an Email template, can have the following attachments: l l The contents of the Print context, in the form of a single PDF attachment.
PAGE 137
5. Write a script that appends a element to the results (the selector is head, so the results contain the
of the email). l l Make sure to set the rel attribute to related. The href attribute determines where the file comes from. For resources inside of the template, use 'images/file.extension' , or 'fonts/myfont.otf', etc. For external resources, you need the full path to the file, such as 'file:///c:/resources/attachments/instructions.pdf'.
PAGE 138
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" on page 174. To split the Print output into several files, see "Splitting printing into more than one file" on page 141. Email output The Email context outputs HTML email with embedded formatting to an email client through the use of an email server.
PAGE 139
l Select File > Print... to print using either of the following options: 1. Using the Default output settings For more details, see "Print Using Standard Print Output Settings" on page 325 2. Using the last used output settings For more details, see "Print Using Standard Print Output Settings" on page 325 3. Using entirely new output settings set via the Advanced option, which allows selection from a myriad of print output options. NOTE: These settings cannot be saved for later re-use.
PAGE 140
Connect Printing options that cannot be changed from within the Printer Wizard. There are a number of settings for the Print context and Print sections that have an impact on how Print sections are printed, which cannot be influenced through either a job creation preset or output creation preset. These settings are: l l l Duplex printing. Duplex printing has to be enabled for a Print section, in order to print that section on both sides of the paper. See "Enabling double-sided printing" on page 181.
PAGE 141
5. In the Preferences dialog, select the print output options you would like to have added to the Print Wizard. How to add print output types from within the Designer Here is how to add print output options from within the main Designer interface itself. 1. Select Window > Preferences... from the menu. Preference dialog is launched. 2. Select Print > Available Printers from the options. 3. In the Available Printers section, select the print output options you would like to have added to the Print Wizard.
PAGE 142
l l The Job Output Mask field in the Print Options, when using the Directory option. The Text, Barcodes, OMR and Image data available in the Additional Content Options page. Available Variables The following is a list of variables that can be used independently of any job options loaded. The Template object Contains information about the template. The default use of ${template} expands to a name based on the template name. A four digit sequence number is added at the end of the basename.
PAGE 143
${template.nr} template file (.OL-template in the example above). An automatic sequence number belonging to the current output file. It is automatically incremented for each new output file that gets created. Note, that multiple output files are created, for example, when output separation has been selected for output creation. It is possible to format the number using a pattern and locale. See Formatting date and number values, below. The extension that corresponds to the chosen output technology.
PAGE 144
If the template file is my-invoices.OL-template and is printed to PostScript, then ${file} expands to my-invoices_0001.ps The name of the template without dot extension (designer context) or the name of the job without dot extenstion (server context) ${file.base} Example (Designer context) If the template file is C:\Data\my-invoices.OL-template, then ${file.base} returns my-invoices The extension that corresponds to the chosen output technology. ${file.ext} For example, for PDF output, ${file.
PAGE 145
${job} is basically a short hand for ${job.base}_${job.nr,0000}.${job.ext} The 0000 in ${job.nr,0000} is a format pattern that takes care of formatting the number with at least four digits including leading zero's. See Formatting date and number values, below. Example If the job name My-Invoices-Reprint.XY2015 gets printed to PDF, then ${job} expands to My-Invoices-Reprint_0001.pdf Returns the base name of the job without any extension. ${job.base} Example If the job name is My-Invoices-Reprint.
PAGE 146
Displays the current system data and/or time. Can be formatted using the Formatting date and number values, below. Value of a meta data property of the document. The propertyname must have been defined as a Tag Name on the Document Tags tab of ${document.metadata. the Meta Data Options page in the AdvancedPrint Wizard. propertyname} Note: this is only available if Separation based on Document has been selected on the Separation page in the AdvancedPrint Wizard.
PAGE 147
specified locale MMMM yyyy", nl} Apply a default format 4 juli 2009 ${expression,,locale} ${system.time,,nl} with the specified locale 12:30:55 It is possible to enclose the values of the pattern and locale in single or double quotes. This is required for including whitespace in a pattern, or when the ${expression} would otherwise be ambiguous. At run-time, the output engine determines the type of the value yielded by the expression. If this is a number, a number pattern is expected.
PAGE 148
Note that the PDF file generated by the Print context is sent as an attachment to the email sent using the information above. PrintShop Mail Search Indexing For PrintShop Mail Search indexing, you can add your own custom fields. Each field that is not included in the above or in Generating Fax output is added as an index for PrintShop Mail Search. For example you could add CustomerID and this would appear as the CustomerID index in Search.
PAGE 149
Output, generated from an Email template, can have the following attachments: l l The contents of the Print context, in the form of a single PDF attachment. Other files, an image or a PDF leaflet for example. Attaching the Print context is one of the options in the Send (Test) Email dialog; see "Generating Email output" on the previous page. To learn how to attach other files, see "Email attachments" on page 136.
PAGE 150
l l l Default SMTP settings can be set in the preferences; see "Email header settings" on page 133. If there are multiple Email sections, only one of them can be merged with each record. Make sure that the correct section has been set as the default; see "Setting a default Email template for output" on page 132. To dynamically select a section for output, use a Control Script; see "Control Scripts" on page 208.
PAGE 151
Personalizing Content Variable-data printing is a form of digital printing in which elements such as text and graphics may be changed using information from a database or data file. It prints unique documents with customized messages for each customer. This is exactly what you can do with Connect: using variable data you can personalize your company's communications. Before you can start personalizing the content of a template, you must open a data file or database; see: "Loading data" on page 153.
PAGE 152
Dynamic images Dynamic Images are dynamic in the sense that they are replaced by another image when a data field contains a certain value. Think of a signature image being swapped based on the sender's name, for example. You can use the Dynamic Image Script Wizard to make this happen; see "Dynamic Images" on page 169. Snippets Snippets are pieces of content that can be re-used within the same template, in all contexts and sections.
PAGE 153
See "Control Scripts" on page 208. Loading data Before you can add variable data fields to a template in the Designer, you need to have a Data Model and a sample of customer data. At the design stage the Designer doesn't have to have access to all data; it just needs to know which data fields exist in your data and it needs some data to be able to display a preview of the output.
PAGE 154
CSV file options o o o o o o Encoding: the Designer can not infer from a CSV file what encoding it is in. The default is right in the large majority of cases, but when it isn't, it can be very difficult to figure out the correct encoding. Ask your source what the encoding of the file is. Field separator: choose the character that separates the fields in the file. Comment delimiter: if there are comment lines in the file, type the character that starts a comment line.
PAGE 155
Adding data from a database 1. Click File, select Add Data and then click From database data source. Browse to the location of the file and select it. The Designer can open databases from the following types of data sources: l l l l l l MySQL Microsoft Access Database (.mdb, .accddb) SQL Server ODBC DataSource JDBC Oracle. 2. Review the options presented. The options available depend on the type of database data source; see below. MySQL 1.
PAGE 156
Microsoft Access 1. Enter the appropriate information to connect to the database: l l File name: Browse to your Microsoft Access database file (.mdb) Password: Enter a password if one is required. 2. Click Next and enter the information for the source table. l l l Connection string: Displays the full path to the database. Table: Use the drop-down to select the appropriate table or stored query to retrieve the appropriate data set.
PAGE 157
2. Click Next and enter the information for the source table. l l l Connection string: Displays the full path to the database. Table: Use the drop-down to select the appropriate table or stored query to retrieve the appropriate data set. Encoding: Use the drop-down to select the encoding with which to read the data in the table. 3. Click Finish to open the database JDBC 1.
PAGE 158
Oracle 1. Enter the appropriate information to connect to the database: l l l l l Server: Enter the server address for the Oracle database. Port: Enter the port to communicate with the Oracle server. Database name: Enter the exact name of the database from where the data should be extracted. User name: Enter a username that has access to the Oracle server and specified database. The user only requires Read access to the database. Password: Enter the password that matches the username above. 2.
PAGE 159
1. To open the Generate Counter Wizard, select File > Add data > Generate counters. 2. Adjust the settings: l l l l l l l Starting value: The starting number for the counter. Defaults to 1. Increment value: The value by which to increment the counter for each record. For example, an increment value of 3 and starting value of 1 would give the counter values of 1, 4, 7, 10, [...] Number of records: The total number of counter records to generate.
PAGE 160
Use the Text Script Wizard when there are empty fields in the data, and the value of a data field needs to be preceded or followed by a space, line break or text in the template. Otherwise, empty data fields will cause empty lines and superfluous white spaces to show up in the text. You should also use this method for blocks of data, such as address blocks, and when you want to format data differently, for example, when you want a number to be displayed as a currency.
PAGE 161
the record set, and each time it replaces the placeholders by the value of the field in the current record. In the Scripts pane you can see that the script has a name and a selector. The drag-and-drop method automatically generates a script that is named after the data field (see the first column of the Scripts pane). The selector (in the second column in the Scripts pane) is the text that the script will replace.
PAGE 162
The Text Script Wizard appears. 2. Change the name of the script so that it reflects what the script does. 3. The selector states the text to be found in the template. The results can be replaced by the script. Tip Hover over the name of a script in the Scripts pane to see which parts of the template are affected by the script. l Text, for example: @lastname@, or {sender}. The text doesn't have to have any special characters, but special characters do make it easier to recognize the text for yourself.
PAGE 163
Note Each ID should be unique. An ID can be used once in each section. n l Etcetera. See http://www.w3schools.com/cssref/css_selectors.asp for more selectors and combinations of selectors. A selector and text. This is text inside an HTML element (or several HTML elements) with a specific HTML tag, class or ID. In the Text Script Wizard, click Selector and text and type the selector and the text in the respective fields. 4. Click the the downward pointing arrow in the first row in the column Field.
PAGE 164
the attribute is src, the script will modify the image's source. The script's results should be a valid value for the chosen attribute. Note When checked, the option Convert fields to JSON string writes the results from the script into an attribute or text as a JSON string. This is useful for web contexts where a front-end script can read this value easily. 9.
PAGE 165
You could also format data in a script using the formatter ; see "API" on page 27. Date Dates in variable data can be displayed as long, medium and short dates with different time displays. There are quite a few presets, but you can also enter a custom format mask. 1. Open the Text Script Wizard: double-click to open an existing script in the Scripts pane or create a new Text Script using the Text Script Wizard; see "Using the Text Script Wizard" on page 161. 2.
PAGE 166
Note The locale influences the way dates, times, numbers and currencies are formatted; see "Locale" on page 240. 4. Close the Script Wizard. For a new script, don’t forget to add the selector to the template. Font style Text originating from variable data can be displayed in uppercase, lowercase or proper case. 1. Open the Text Script Wizard: double-click to open an existing script in the Scripts pane or create a new Text Script using the Text Script Wizard; see "Using the Text Script Wizard" on page 161.
PAGE 167
l l Currency displays a number as an amount of money, with a thousands separator and rounded to two decimal places, based on the current locale; see "Locale" on page 240. Currency no symbol does the same as Currency, but omits the currency symbol. 4. Close the Script Wizard. For a new script, don’t forget to add the selector to the template. Showing content conditionally One way to personalize content is to show or hide one or more elements depending on a field’s value.
PAGE 168
6. Click the downward pointing arrow next to Condition to expand the list of conditions with which the data field can be evaluated. The options are: Equal to, Not equal to, Contains, Does not contain, Begins with, Ends with. 7. Type the Value that should be used for the conditional check. For example, you could check whether the data field Gender is 'Equal To' the value 'M', in order to show a paragraph or an image applying to male customers only.
PAGE 169
click those words; the paragraph as a whole will be made conditional. It is, however, possible to partially show or hide a paragraph or a line item in a list. Before you can do that, you have to select the text that you want to be shown or hidden and wrap it in a span element first: 1. Select the part of the text that you want to make conditional. 2. Right-click the selected text and click Wrap in span. 3. Type an ID and/or a class.
PAGE 170
l l l The prefix shows the path of the image. The suffix states the file extension of the image. The file name is the value of the data field(s) in the Field column. The prefix and suffix are derived from the current image. 3. If necessary, enter another Prefix and/or Suffix. 4. Click the first field in the column Field, and then click the downward pointing arrow. Select the data field to be evaluated.
PAGE 171
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" on page 138). The Print context can also be added to Email output as a PDF attachment; see "Generating Email output" on page 148. 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.
PAGE 172
Stationery (Media) When the output of a Print context is meant to be printed on paper that already has graphical and text elements on it (called stationery, or preprinted sheets), you can add a copy of this media, in the form of a PDF file, to the Media folder. Media can be applied to pages in a Print section, to make them appear as a background to those pages. This ensures that elements added to the Print context will correspond to their correct location on the preprinted media.
PAGE 173
Tip To create a Print section from an existing PDF file, use a PDF file as a Print section's background. Editing PDF files in the Designer is not possible, but when they're used as a section's background, you can add text and other elements, such as a barcode, to them. See "Using a PDF file as background image" on page 179. When a Print template is created, the following happens: l l The Print context is created and one Print section is added to it.
PAGE 174
l pages in the Print section. You can add more Media and apply them each to different pages. One Stylesheet, named context_print_styles.css, is added to the template, as you can see on the Resources pane, in the Stylesheets folder. This stylesheet is meant to be used for styles that are only applied to elements in the Print context. See also "Styling templates with CSS files" on page 219.
PAGE 175
1. On the Resources pane, expand the Contexts folder, and right-click the Print context. 2. Click Properties. 3. Choose a Binding style and, if applicable, the number of holes. To set the binding style of a Print section, see "Setting the binding style for a Print section" on page 180. Overriding binding styles in a job creation preset A Job Creation Preset can override the binding styles set for the Print sections and for the Print context as a whole.
PAGE 176
See "Pages" on page 182 for an overview of settings and elements that are specific for pages. Using headers, footers, tear-offs and repeated elements In Print sections, there are often elements that need to be repeated across pages, like headers, footers and logos. In addition, some elements should appear on each first page, or only on pages in between the first and the last page, or only on the last page.
PAGE 177
Adding a Print section The Print context can contain multiple sections: a covering letter and a policy, for example, or one section that is meant to be attached to an email as a PDF file and another one that is meant to be printed out on paper. When a Print template is created (see "Creating a Print template with a Wizard" on page 244 and "Print context" on page 172), only one Print section is added to it, but you can add as many print sections as you need.
PAGE 178
Arranging Print sections 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. The sections are added to the output in the order in which they appear on the Resources pane, so changing the order of the sections in the Print context changes the order in which they are outputted to the final document.
PAGE 179
Using a PDF file as background image In the Print context, a PDF file can be used as a section's background. It is different from the Media in that the section considers the PDF to be content, so the number of pages in the section will be the same as the number of pages taken from the PDF file. With this feature it is possible to create a Print template from an arbitrary PDF file.
PAGE 180
Note It is not possible to use a remotely stored PDF file as a section's background, because the number of pages in a PDF file can not be determined via the http and http protocols. Therefor, with an external image, the option Save with template is always checked. 4. Select the PDF's position: l l l Fit to page stretches the PDF to fit the page size. Centered centers the PDF on the page, vertically and horizontally. Absolute places the PDF at a specific location on the page.
PAGE 181
1. On the Resources pane, expand the Contexts folder, expand the Print context and rightclick the Print section. 2. Click Finishing. 3. Choose a Binding style and, if applicable, the number of holes. To set the binding style of the Print context, see "Setting the binding style for the Print context" on page 174. Overriding binding styles in a job creation preset A Job Creation Preset can override the binding styles set for the Print sections and for the Print context as a whole.
PAGE 182
this page from page counting, check the option Omit Master Page Back in case of an empty back page. Pages Unlike emails, Print sections can contain multiple pages. Pages are naturally limited by their size and margins. If the content of a section doesn't fit on one page, the overflow goes to the next page. This happens automatically, based on the section's page size and margins; see "Page settings: size, margins and bleed" on the next page.
PAGE 183
When it comes to positioning elements on a page, Guides can be useful, as well as Tables. See "How to position elements" on page 230. Page settings: size, margins and bleed On paper, whether it is real or virtual, content is naturally limited by the page size and margins. These, as well as the bleed, are set per Print section, as follows: l On the Resources pane, right-click a section in the Print context and click Properties.
PAGE 184
1. Import the promotional image or snippet; see "Images" on page 119 and "Snippets" on page 216. 2. Insert the promotional image or snippet in the content. Note l l Only a top-level element (for example, a paragraph that is not inside a table or div) can function as a whitespace element. Do not place the promotional image or snippet inside an absolute positioned box. Whitespacing only works for elements that are part of the text flow, not for absolute-positioned boxes. 3.
PAGE 185
l l l Content page count: This is the total number of pages in the current document that have contents, supplied by the Print section. A page that has a Master Page but no contents, is not included in the Content page count. Sheet number: The current sheet number in the document. A sheet is a physical piece of paper, with two sides (or pages). This is equivalent to half the page number, for example if there are 10 pages, there will be 5 sheets.
PAGE 186
1. Open the style sheet for the Print context: on the Resources pane, expand the Styles folder and double-click context_print_styles.css. 2. Add a CSS rule, like the following: p { widows: 4; orphans: 3 } Per paragraph To change the widow or orphan setting for one paragraph only: 1. Select the paragraph, using the breadcrumbs or the Outline pane (next to the Resources pane). 2. On the Format menu, click Paragraph. 3.
PAGE 187
l In the Breaks group, set the before or after property. l l Before: Sets whether a page break should occur before the element. This is equivalent to the page-break-before property in CSS; see CSS page-break-before property for an explanation of the available options. After: Sets whether a page break should occur after the element. Equivalent to the page-break-after property in CSS; see CSS page-break-after property for an explanation of the available options.
PAGE 188
Master Pages resemble Print sections, and they are edited much the same way, see "Editing a Master Page" below; but they contain a single page and do not have any text flow. Only one Master Page can be applied per page in printed output. When a Print template is created, one master page is added to it automatically. You can add more Master Pages; see "Adding a Master Page" below.
PAGE 189
is good practice to position elements on a Master Page by placing them in a Positioned Box (see "Content elements" on page 72). Keep in mind that a Master Page always remains a single page. Its content cannot overflow to a next page. Content that doesn't fit, will not be displayed. Note Editing the Master Page is optional. One Master Page must always exist in a Print template, but if you don't need it, you can leave it empty.
PAGE 190
Applying a Master Page to a page in a Print section Every page in a print section has a natural position: it can be the first page, the last page, one of the pages in between (a 'middle page'), or a single page. For each of those positions, you can set a different Master Page and Media (see "Media" below). It can even have two master pages, if printing is done on both sides (called duplex printing). To apply Master Pages to specific page positions in a Print section: 1.
PAGE 191
Media can be applied to pages in a Print section, to make them appear as a background to those pages. This ensures that elements added to the Print context will correspond to their correct location on the preprinted media. For further explanation about how to apply Media to different pages, see "Applying Media to a page in a Print section" on page 193. Media will not be printed, unless you want them to; see below.
PAGE 192
1. On the Resources pane, expand the Contexts folder, expand the Media folder, rightclick the Media and click Virtual Stationery. 2. Click the Select Image button to select a PDF image file. 3. Click Resources, Disk or Url, depending on where the image is located. l l l Resources lists the PDF files that are present in the Images folder on the Resources pane. Disk lets you choose an image file that resides in a folder on a hard drive that is accessible from your computer.
PAGE 193
1. On the Resources pane, expand the Contexts folder, expand the Media folder, and right-click the Media. Click Characteristics. 2. Specify the paper's characteristics: l l l l l l l Media Type: The type of paper, such as Plain, Continuous, Envelope, Labels, Stationery, etc. Weight: The intended weight of the media in grammage (g/m2). Front Coating: The pre-process coating applied to the front surface of the media, such as Glossy, High Gloss, Matte, Satin, etc.
PAGE 194
3. If the option Same for all positions is checked, the same Media will be applied to every page in the print section. Uncheck this option. 4. Decide which Media should be linked to each sheet position: click the downward pointing arrow after Media and select a Media. 5. Optionally, decide which Master Page should be linked to each sheet; see "Master Pages" on page 187.
PAGE 195
See "Write your own scripts" below if you are not familiar with how scripts are written. 5. Click Apply, open the tab Preview and browse through the records to see if the script functions as expected. 6. When you click OK, the script will be added to the Scripts pane. Printing virtual stationery Media are not printed, unless you want them to. Printing the virtual stationery is one of the settings in a Job Creation Preset. To have the virtual stationery printed as part of the Print output: 1.
PAGE 196
When Connect generates the actual output – letters, web pages or emails -, it opens a record set and merges it with the template. It takes each record, one by one, and runs all scripts for it (Control Scripts first). All scripts, except Control Scripts, must have a selector. The selector can be text, an HTML element and/or a CSS selector. Running a script starts with looking for pieces of content in the template that match the script's selector.
PAGE 197
l A selector (HTML/CSS): n n n n l HTML elements of a certain type, such as a paragraph:
. In the script Wizard, click Selector and type the HTML tag without the angle brackets: p. HTML elements with a specific CSS class (.green). In the script Wizard, click Selector and type the class name, including the preceding dot: .green. An HTML element with a specific ID (#intro). In the script Wizard, click Selector and type the ID, including the preceding #: #intro.
PAGE 198
Warning When you change an expanded text script and save it, it becomes impossible to edit the script using the Script Wizard again. 2. Write the script. Click Apply from time to time to see if the script works as expected. This will be visible on the Preview tab in the main workspace. Syntax rules Every script in the Designer must follow JavaScript syntax rules. For example, each statement should end with ; and the keywords that can be used, such as var to declare a variable, are JavaScript keywords.
PAGE 199
It does this for each and every customer, because it does not depend on a value from the record that is being merged to the template. Using values from the record in a script To access the record that is being merged to the template when the script runs, use the object record. Suppose you want to display negative amounts in red and positive amounts in green. Assuming that there is an AMOUNT field in your customer data, you could write the following script (with the selector: td.
PAGE 200
The order in which scripts are executed is particularly important when one script produces content that contains a selector for another script. If the other script has already been executed, it will not run again automatically. So, scripts that produce content that contains one or more selectors for other scripts, need to come first. To change the order in which scripts are executed: l Click a script or a folder in the Scripts pane at the bottom. Drag it up or down and drop it.
PAGE 201
Tip It may be helpful to put scripts that have an effect on the same context or section in one folder, because you can set the execution scope of scripts per folder (see: "Execution scope" below). Note Control scripts are always executed first, regardless of where they are in the Scripts pane. They can not be excluded from execution for a specific context or section, using the execution scope of a folder; see "Execution scope" below.
PAGE 202
Enable/disable scripts A disabled script will not run at all when the template is merged with a record set to generate output. When you disable a folder, all scripts in the folder will be disabled. To enable or disable a script or a folder: l On the Scripts pane, right-click the script or the folder and click Disable (if the script or folder was enabled) or Enable (if the script or folder was disabled). Import/export scripts Scripts can be exported - one at a time - for use in other templates.
PAGE 203
Note that scripts that use values of data fields can only be effective when a data file is open. See "Loading data" on page 153. Test for errors Another way to 'test' a script is to take a look at the Scripts pane. Tip Hover over the name of a script in the Scripts pane to see which parts of the template are affected by the script. Icons on the name of scripts in the Scripts pane can show a warning, information or error icon.
PAGE 204
Test for speed issues To measure the time that the execution of scripts will take: l On the Context menu, click Profile scripts. Profiling means running the scripts in the template, to see how fast scripts in the Scripts pane execute. It helps greatly in troubleshooting performance issues caused by scripts. After running the Script Profiler you can see in which sections the script has run: l Hover the mouse over a value in the column Count to see the number of times that the script has run, per section.
PAGE 205
comparatively time consuming. Avoid using such functions in a loop. Note that the times vary slightly per run of the Script Profiler. Run the Script Profiler a number of times and calculate an average from the results, before trying to speed up the execution of a script. Script Profiler settings Number of runs By default, the Script Profiler runs on 1000 instances of all the scripts. To test on a higher or lower number of instances: 1. On the Window menu, click Preferences 2. Click Scripting 3.
PAGE 206
print/email. loadhtml(location) Loads all HTML from the HTML file. locationString containing a path that can be absolute or relative to the section/context. Use: snippets/ to retrieve the content from a HTML file residing in the Snippets folder on the Resources panel.ExamplesThis script loads a local HTML snippet (from the Resources panel) directly into the matched elementsresults.loadhtml("snippets/snippet.
PAGE 207
See the Designer API for more information about this function. Loading a snippet, depending on the value of a data field To load a snippet depending on the value of a data field, you have to add a condition to the script. Example The following script evaluates if the value of the LANGUAGE field in the record is ‘En’. If so, the snippet is added to the content. if (record.fields.LANGUAGE == ‘En’) { results.loadhtml(‘snippets/nameofthesnippet.
PAGE 208
that container an ID, for example:
This is text for English customers.
Use the function .children() to load the contents of the container, and not the container itself. For example: results.loadhtml(‘Snippets/myfooter.html’, ‘#EN’).children() This script loads the paragraph of the example (), but not the container itself (
).
PAGE 209
For examples and for more uses of Control Scripts, see the sample scripts in the Control Script API: "Sample scripts" on page 66. Tip New Control Scripts added to the template contain a few examples. For more examples see "Sample scripts" on page 66. Adding a Control Script To add a Control Script: 1. On the Scripts pane at the bottom left, click the black triangle on the New button and click New Control Script. A new script appears in the list. 2. Double-click the new script to open it.
PAGE 210
3. Section C page 2 4. Section D page 1 Note that even if a section is not enabled, its restartPageNumber flag is still taken into account for composing the page number sequences. So, if the restartPageNumber flags are set as follows: 1. 2. 3. 4. Section A (1 page) restartPageNumber = true Section B (2 pages) restartPageNumber = false Section C (3 pages) restartPageNumber = true, enabled = false Section D (4 pages) restartPageNumber = false the page numbering in the output will be: 1. Section A page 1 2.
PAGE 211
Example 1: no parts defined Assume there are three Print sections: sections A, B and C. When generating Email output with the Print context as attachment, all three Print sections will be put together in one file and attached to the email. Example 2: 2 parts Assume there are three Print sections: sections A, B and C. In a Control Script a part name is defined for section C: var section = merge.template.contexts.PRINT.sections['Section C']; section.
PAGE 212
After that, the background can be positioned, setting the section's background.position to ABSOLUTE or to FIT_TO_MEDIA. For examples, see the Control Script API: "Sample scripts" on page 66. Sections Sections are parts of one of the contexts in a template: Print or Email. They contain the main text flow for the contents. In each of the contexts there can be multiple sections. A Print context, for example, may consist of two sections: a covering letter and a policy.
PAGE 213
1. Open the section that you want to copy and go to the Source tab in the workspace. 2. Copy the contents of the Source tab (press Ctrl+A to select everything and then Ctrl+C to copy the selection). 3. Add a new section (see Adding a section). 4. Go to the Source tab and paste the contents of the other section here (press Ctrl+V). 5. When copying a section to another template, add the related source files, such as images, to the other template as well.
PAGE 214
To change the properties for a section: l On the Resources pane, expand the Contexts folder, expand the folder of the respective context, right-click the name of the section, and then click one of the options. Applying a style sheet to a section In order for a style sheet to be applied to a specific section, it needs to be included in that section. There are two ways to do this. Drag & drop a style sheet 1. Click and hold the mouse button on the style sheet on the Resources pane. 2.
PAGE 215
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. The sections are added to the output in the order in which they appear on the Resources pane. See "Generating Print output" on page 138. In email output, only one section can be executed at a time. The section that will be output is the section that has been set as the 'default'.
PAGE 216
Skin/Formats/CrossReferencePrintFormat("Email attachments" on page 1)." on page 1) to learn how to generate Print documents or Email. Snippets A snippet is a small, ready-to-use piece of content in a file. Snippets can be re-used within the same template, in all contexts and sections. They can contain any contents that a section can have, such as text, images, variable data, dynamic tables, etc.
PAGE 217
It is also possible, and often useful, to insert a snippet or part of it, using a script. See "Loading a snippet via a script" on page 205. Creating a snippet To turn a parts of a letter or email into a snippet for reuse in the content of a template: 1. Select the part that should be saved in a snippet. 2. Right-click the selection, point to Snippet and click Create. 3. Right-click the new snippet on the Resources pane in the Snippets folder and rename it.
PAGE 218
Whether applied through style sheets or through local formatting, behind the scenes all layout properties in the Designer are CSS properties. When you format an element locally, an inline style rule is added to the element. Note that where local formatting conflicts with a formatting rule for the same element in one of the style sheets, the local formatting rule gets priority; the rule in the style sheet will be ignored.
PAGE 219
The locale setting influences how dates, numbers and amounts of money are displayed; see "Locale" on page 240. Styling templates with CSS files The Layout toolbar and the Format menu offer many possibilities to style every piece of a template. However, styling every single element, one after another, is a lot of work and, more importantly, can result in a template with a messy mix of styles that isn’t easy to maintain and lacks consistent design.
PAGE 220
On this tab you can view and edit the content of the template in the form of plain text with HTML tags (note the angle brackets: <>). You may add and edit the text and the HTML tags, classes, ID’s and other attributes. To learn more about HTML, see for example https://developer.mozilla.org/enUS/docs/Web/Guide/HTML/Introduction and http://www.w3schools.com/html/default.asp. Many video courses and hands-on courses about HTML (and CSS) are offered on the Internet as well, some for free.
PAGE 221
Tip To export a CSS file from your template, drag or copy/paste it out of the Stylesheets folder to a folder on the local hard drive. Note The order in which style sheets are executed, can affect the actual output. This sequence can be set per section; see "Determining the order in which style sheets are read" on page 226. Using a remote style sheet A remote style sheet is not located within your template but is rather hosted on an external web server (generally called a CDN).
PAGE 222
Styling your templates with CSS files Note Email clients do not read CSS files and some even remove a
PAGE 127
In HTML text can be contained in many different elements: paragraphs, span elements, line items and table cells, for example. The HTML tag of a paragraph is
. The paragraph should be followed by a closing tag:
. A line break looks like this in HTML:. Formatting text Text can be styled, colored, centered, indented etc. It can even be displayed so that it reads from right to left. See "Styling text and paragraphs" on page 226.
PAGE 128
Email templates are personalized just like any other template; see "Variable Data" on page 159. Sending email When the template is ready, you can change the email settings (see "Email header settings" on page 133) and send the email. To test a template, you can send a test email first.
PAGE 129
Sending email When the template is ready, you can generate Email output; See "Generating Email output" on page 148. To test a template, you can send a test email first. Email output can have the following attachments: l l l The contents of the Print context, in the form of one PDF attachment. The default section of the Web context, as an integral HTML file. Other files.
PAGE 130
decompressed. When low Quality values are used to optimize images smaller than 1024 x 1024 pixels, using the largest tile size will produce better results. Setting a default section for output When generating output from the Email context, only one of the Email templates can be merged with each record. One of the Email sections is the 'default'; see "Setting a default Email template for output" on page 132.
PAGE 131
To provide alternative content for your email, you could use Conditional Content (see "Showing content conditionally" on page 167), or Snippets and a script (see "Snippets" on page 216 and "Loading a snippet via a script" on page 205). If you would like to start with a template that is identical to the one you already have, consider copying it (see "Copying a section" on page 212).
PAGE 132
Tip Before you can style an element, you have to select it. In an Email context it can be difficult to select an element by clicking on it. Use the breadcrumbs at the top and the Outline pane at the left, to select an element. See "Selecting an element" on page 76. In order for a style sheet to be applied to a specific section, it needs to be included in that section. There are two ways to do this. Drag & drop a style sheet 1. Click and hold the mouse button on the style sheet on the Resources pane. 2.
PAGE 133
value of a data field. Email header settings Email header settings define the information that goes into the header of each email that is generated from an Email template. The default Email SMTP settings and the sender's name and address are defined in the preferences and can be adjusted in the Send Email and Send Test Email dialogs. The subject, the recipients (To, CC and BCC), the sender and the reply-to address can be specified with Email Script Wizards.
PAGE 134
In the Send Email and Send Test Email dialogs you will be able to choose one of the three presets and adjust the settings to your needs. Subject To specify a subject for an email template: 1. On the Resources pane, expand the Contexts folder, and expand the Email section. 2. Right-click the section of which the subject should change and click Properties. Now you can change the subject. Creating a dynamic subject with variable data To replace an Email section's subject by a dynamic subject: 1.
PAGE 135
The result of this script goes in the email's To, CC, or BCC address field, respectively. It should be a valid, fully-formed email address. Sender From address A default From name and email address can be specified in the Preferences dialog: select Window > Preferences, expand the Email preferences and click General. This name and email address will appear as the default in the Send Email and Send Test Email dialogs. To dynamically specify a From address you have to use the Email From Script Wizard: 1.
PAGE 136
To define a password to protect the generated PDF attachment: 1. On the Scripts pane, click the black triangle on the New button and click Email PDF password Script. A new script is added to the Scripts pane. 2. Double-click the new script to open it. 3. Select a data field and optionally, type a prefix and/or suffix. Email attachments Output, generated from an Email template, can have the following attachments: l l The contents of the Print context, in the form of a single PDF attachment.
PAGE 137
5. Write a script that appends a element to the results (the selector is head, so the results contain the
of the email). l l Make sure to set the rel attribute to related. The href attribute determines where the file comes from. For resources inside of the template, use 'images/file.extension' , or 'fonts/myfont.otf', etc. For external resources, you need the full path to the file, such as 'file:///c:/resources/attachments/instructions.pdf'.PAGE 138
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" on page 174. To split the Print output into several files, see "Splitting printing into more than one file" on page 141. Email output The Email context outputs HTML email with embedded formatting to an email client through the use of an email server.
PAGE 139
l Select File > Print... to print using either of the following options: 1. Using the Default output settings For more details, see "Print Using Standard Print Output Settings" on page 325 2. Using the last used output settings For more details, see "Print Using Standard Print Output Settings" on page 325 3. Using entirely new output settings set via the Advanced option, which allows selection from a myriad of print output options. NOTE: These settings cannot be saved for later re-use.
PAGE 140
Connect Printing options that cannot be changed from within the Printer Wizard. There are a number of settings for the Print context and Print sections that have an impact on how Print sections are printed, which cannot be influenced through either a job creation preset or output creation preset. These settings are: l l l Duplex printing. Duplex printing has to be enabled for a Print section, in order to print that section on both sides of the paper. See "Enabling double-sided printing" on page 181.
PAGE 141
5. In the Preferences dialog, select the print output options you would like to have added to the Print Wizard. How to add print output types from within the Designer Here is how to add print output options from within the main Designer interface itself. 1. Select Window > Preferences... from the menu. Preference dialog is launched. 2. Select Print > Available Printers from the options. 3. In the Available Printers section, select the print output options you would like to have added to the Print Wizard.
PAGE 142
l l The Job Output Mask field in the Print Options, when using the Directory option. The Text, Barcodes, OMR and Image data available in the Additional Content Options page. Available Variables The following is a list of variables that can be used independently of any job options loaded. The Template object Contains information about the template. The default use of ${template} expands to a name based on the template name. A four digit sequence number is added at the end of the basename.
PAGE 143
${template.nr} template file (.OL-template in the example above). An automatic sequence number belonging to the current output file. It is automatically incremented for each new output file that gets created. Note, that multiple output files are created, for example, when output separation has been selected for output creation. It is possible to format the number using a pattern and locale. See Formatting date and number values, below. The extension that corresponds to the chosen output technology.
PAGE 144
If the template file is my-invoices.OL-template and is printed to PostScript, then ${file} expands to my-invoices_0001.ps The name of the template without dot extension (designer context) or the name of the job without dot extenstion (server context) ${file.base} Example (Designer context) If the template file is C:\Data\my-invoices.OL-template, then ${file.base} returns my-invoices The extension that corresponds to the chosen output technology. ${file.ext} For example, for PDF output, ${file.
PAGE 145
${job} is basically a short hand for ${job.base}_${job.nr,0000}.${job.ext} The 0000 in ${job.nr,0000} is a format pattern that takes care of formatting the number with at least four digits including leading zero's. See Formatting date and number values, below. Example If the job name My-Invoices-Reprint.XY2015 gets printed to PDF, then ${job} expands to My-Invoices-Reprint_0001.pdf Returns the base name of the job without any extension. ${job.base} Example If the job name is My-Invoices-Reprint.
PAGE 146
Displays the current system data and/or time. Can be formatted using the Formatting date and number values, below. Value of a meta data property of the document. The propertyname must have been defined as a Tag Name on the Document Tags tab of ${document.metadata. the Meta Data Options page in the AdvancedPrint Wizard. propertyname} Note: this is only available if Separation based on Document has been selected on the Separation page in the AdvancedPrint Wizard.
PAGE 147
specified locale MMMM yyyy", nl} Apply a default format 4 juli 2009 ${expression,,locale} ${system.time,,nl} with the specified locale 12:30:55 It is possible to enclose the values of the pattern and locale in single or double quotes. This is required for including whitespace in a pattern, or when the ${expression} would otherwise be ambiguous. At run-time, the output engine determines the type of the value yielded by the expression. If this is a number, a number pattern is expected.
PAGE 148
Note that the PDF file generated by the Print context is sent as an attachment to the email sent using the information above. PrintShop Mail Search Indexing For PrintShop Mail Search indexing, you can add your own custom fields. Each field that is not included in the above or in Generating Fax output is added as an index for PrintShop Mail Search. For example you could add CustomerID and this would appear as the CustomerID index in Search.
PAGE 149
Output, generated from an Email template, can have the following attachments: l l The contents of the Print context, in the form of a single PDF attachment. Other files, an image or a PDF leaflet for example. Attaching the Print context is one of the options in the Send (Test) Email dialog; see "Generating Email output" on the previous page. To learn how to attach other files, see "Email attachments" on page 136.
PAGE 150
l l l Default SMTP settings can be set in the preferences; see "Email header settings" on page 133. If there are multiple Email sections, only one of them can be merged with each record. Make sure that the correct section has been set as the default; see "Setting a default Email template for output" on page 132. To dynamically select a section for output, use a Control Script; see "Control Scripts" on page 208.
PAGE 151
Personalizing Content Variable-data printing is a form of digital printing in which elements such as text and graphics may be changed using information from a database or data file. It prints unique documents with customized messages for each customer. This is exactly what you can do with Connect: using variable data you can personalize your company's communications. Before you can start personalizing the content of a template, you must open a data file or database; see: "Loading data" on page 153.
PAGE 152
Dynamic images Dynamic Images are dynamic in the sense that they are replaced by another image when a data field contains a certain value. Think of a signature image being swapped based on the sender's name, for example. You can use the Dynamic Image Script Wizard to make this happen; see "Dynamic Images" on page 169. Snippets Snippets are pieces of content that can be re-used within the same template, in all contexts and sections.
PAGE 153
See "Control Scripts" on page 208. Loading data Before you can add variable data fields to a template in the Designer, you need to have a Data Model and a sample of customer data. At the design stage the Designer doesn't have to have access to all data; it just needs to know which data fields exist in your data and it needs some data to be able to display a preview of the output.
PAGE 154
CSV file options o o o o o o Encoding: the Designer can not infer from a CSV file what encoding it is in. The default is right in the large majority of cases, but when it isn't, it can be very difficult to figure out the correct encoding. Ask your source what the encoding of the file is. Field separator: choose the character that separates the fields in the file. Comment delimiter: if there are comment lines in the file, type the character that starts a comment line.
PAGE 155
Adding data from a database 1. Click File, select Add Data and then click From database data source. Browse to the location of the file and select it. The Designer can open databases from the following types of data sources: l l l l l l MySQL Microsoft Access Database (.mdb, .accddb) SQL Server ODBC DataSource JDBC Oracle. 2. Review the options presented. The options available depend on the type of database data source; see below. MySQL 1.
PAGE 156
Microsoft Access 1. Enter the appropriate information to connect to the database: l l File name: Browse to your Microsoft Access database file (.mdb) Password: Enter a password if one is required. 2. Click Next and enter the information for the source table. l l l Connection string: Displays the full path to the database. Table: Use the drop-down to select the appropriate table or stored query to retrieve the appropriate data set.
PAGE 157
2. Click Next and enter the information for the source table. l l l Connection string: Displays the full path to the database. Table: Use the drop-down to select the appropriate table or stored query to retrieve the appropriate data set. Encoding: Use the drop-down to select the encoding with which to read the data in the table. 3. Click Finish to open the database JDBC 1.
PAGE 158
Oracle 1. Enter the appropriate information to connect to the database: l l l l l Server: Enter the server address for the Oracle database. Port: Enter the port to communicate with the Oracle server. Database name: Enter the exact name of the database from where the data should be extracted. User name: Enter a username that has access to the Oracle server and specified database. The user only requires Read access to the database. Password: Enter the password that matches the username above. 2.
PAGE 159
1. To open the Generate Counter Wizard, select File > Add data > Generate counters. 2. Adjust the settings: l l l l l l l Starting value: The starting number for the counter. Defaults to 1. Increment value: The value by which to increment the counter for each record. For example, an increment value of 3 and starting value of 1 would give the counter values of 1, 4, 7, 10, [...] Number of records: The total number of counter records to generate.
PAGE 160
Use the Text Script Wizard when there are empty fields in the data, and the value of a data field needs to be preceded or followed by a space, line break or text in the template. Otherwise, empty data fields will cause empty lines and superfluous white spaces to show up in the text. You should also use this method for blocks of data, such as address blocks, and when you want to format data differently, for example, when you want a number to be displayed as a currency.
PAGE 161
the record set, and each time it replaces the placeholders by the value of the field in the current record. In the Scripts pane you can see that the script has a name and a selector. The drag-and-drop method automatically generates a script that is named after the data field (see the first column of the Scripts pane). The selector (in the second column in the Scripts pane) is the text that the script will replace.
PAGE 162
The Text Script Wizard appears. 2. Change the name of the script so that it reflects what the script does. 3. The selector states the text to be found in the template. The results can be replaced by the script. Tip Hover over the name of a script in the Scripts pane to see which parts of the template are affected by the script. l Text, for example: @lastname@, or {sender}. The text doesn't have to have any special characters, but special characters do make it easier to recognize the text for yourself.
PAGE 163
Note Each ID should be unique. An ID can be used once in each section. n l Etcetera. See http://www.w3schools.com/cssref/css_selectors.asp for more selectors and combinations of selectors. A selector and text. This is text inside an HTML element (or several HTML elements) with a specific HTML tag, class or ID. In the Text Script Wizard, click Selector and text and type the selector and the text in the respective fields. 4. Click the the downward pointing arrow in the first row in the column Field.
PAGE 164
the attribute is src, the script will modify the image's source. The script's results should be a valid value for the chosen attribute. Note When checked, the option Convert fields to JSON string writes the results from the script into an attribute or text as a JSON string. This is useful for web contexts where a front-end script can read this value easily. 9.
PAGE 165
You could also format data in a script using the formatter ; see "API" on page 27. Date Dates in variable data can be displayed as long, medium and short dates with different time displays. There are quite a few presets, but you can also enter a custom format mask. 1. Open the Text Script Wizard: double-click to open an existing script in the Scripts pane or create a new Text Script using the Text Script Wizard; see "Using the Text Script Wizard" on page 161. 2.
PAGE 166
Note The locale influences the way dates, times, numbers and currencies are formatted; see "Locale" on page 240. 4. Close the Script Wizard. For a new script, don’t forget to add the selector to the template. Font style Text originating from variable data can be displayed in uppercase, lowercase or proper case. 1. Open the Text Script Wizard: double-click to open an existing script in the Scripts pane or create a new Text Script using the Text Script Wizard; see "Using the Text Script Wizard" on page 161.
PAGE 167
l l Currency displays a number as an amount of money, with a thousands separator and rounded to two decimal places, based on the current locale; see "Locale" on page 240. Currency no symbol does the same as Currency, but omits the currency symbol. 4. Close the Script Wizard. For a new script, don’t forget to add the selector to the template. Showing content conditionally One way to personalize content is to show or hide one or more elements depending on a field’s value.
PAGE 168
6. Click the downward pointing arrow next to Condition to expand the list of conditions with which the data field can be evaluated. The options are: Equal to, Not equal to, Contains, Does not contain, Begins with, Ends with. 7. Type the Value that should be used for the conditional check. For example, you could check whether the data field Gender is 'Equal To' the value 'M', in order to show a paragraph or an image applying to male customers only.
PAGE 169
click those words; the paragraph as a whole will be made conditional. It is, however, possible to partially show or hide a paragraph or a line item in a list. Before you can do that, you have to select the text that you want to be shown or hidden and wrap it in a span element first: 1. Select the part of the text that you want to make conditional. 2. Right-click the selected text and click Wrap in span. 3. Type an ID and/or a class.
PAGE 170
l l l The prefix shows the path of the image. The suffix states the file extension of the image. The file name is the value of the data field(s) in the Field column. The prefix and suffix are derived from the current image. 3. If necessary, enter another Prefix and/or Suffix. 4. Click the first field in the column Field, and then click the downward pointing arrow. Select the data field to be evaluated.
PAGE 171
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" on page 138). The Print context can also be added to Email output as a PDF attachment; see "Generating Email output" on page 148. 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.
PAGE 172
Stationery (Media) When the output of a Print context is meant to be printed on paper that already has graphical and text elements on it (called stationery, or preprinted sheets), you can add a copy of this media, in the form of a PDF file, to the Media folder. Media can be applied to pages in a Print section, to make them appear as a background to those pages. This ensures that elements added to the Print context will correspond to their correct location on the preprinted media.
PAGE 173
Tip To create a Print section from an existing PDF file, use a PDF file as a Print section's background. Editing PDF files in the Designer is not possible, but when they're used as a section's background, you can add text and other elements, such as a barcode, to them. See "Using a PDF file as background image" on page 179. When a Print template is created, the following happens: l l The Print context is created and one Print section is added to it.
PAGE 174
l pages in the Print section. You can add more Media and apply them each to different pages. One Stylesheet, named context_print_styles.css, is added to the template, as you can see on the Resources pane, in the Stylesheets folder. This stylesheet is meant to be used for styles that are only applied to elements in the Print context. See also "Styling templates with CSS files" on page 219.
PAGE 175
1. On the Resources pane, expand the Contexts folder, and right-click the Print context. 2. Click Properties. 3. Choose a Binding style and, if applicable, the number of holes. To set the binding style of a Print section, see "Setting the binding style for a Print section" on page 180. Overriding binding styles in a job creation preset A Job Creation Preset can override the binding styles set for the Print sections and for the Print context as a whole.
PAGE 176
See "Pages" on page 182 for an overview of settings and elements that are specific for pages. Using headers, footers, tear-offs and repeated elements In Print sections, there are often elements that need to be repeated across pages, like headers, footers and logos. In addition, some elements should appear on each first page, or only on pages in between the first and the last page, or only on the last page.
PAGE 177
Adding a Print section The Print context can contain multiple sections: a covering letter and a policy, for example, or one section that is meant to be attached to an email as a PDF file and another one that is meant to be printed out on paper. When a Print template is created (see "Creating a Print template with a Wizard" on page 244 and "Print context" on page 172), only one Print section is added to it, but you can add as many print sections as you need.
PAGE 178
Arranging Print sections 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. The sections are added to the output in the order in which they appear on the Resources pane, so changing the order of the sections in the Print context changes the order in which they are outputted to the final document.
PAGE 179
Using a PDF file as background image In the Print context, a PDF file can be used as a section's background. It is different from the Media in that the section considers the PDF to be content, so the number of pages in the section will be the same as the number of pages taken from the PDF file. With this feature it is possible to create a Print template from an arbitrary PDF file.
PAGE 180
Note It is not possible to use a remotely stored PDF file as a section's background, because the number of pages in a PDF file can not be determined via the http and http protocols. Therefor, with an external image, the option Save with template is always checked. 4. Select the PDF's position: l l l Fit to page stretches the PDF to fit the page size. Centered centers the PDF on the page, vertically and horizontally. Absolute places the PDF at a specific location on the page.
PAGE 181
1. On the Resources pane, expand the Contexts folder, expand the Print context and rightclick the Print section. 2. Click Finishing. 3. Choose a Binding style and, if applicable, the number of holes. To set the binding style of the Print context, see "Setting the binding style for the Print context" on page 174. Overriding binding styles in a job creation preset A Job Creation Preset can override the binding styles set for the Print sections and for the Print context as a whole.
PAGE 182
this page from page counting, check the option Omit Master Page Back in case of an empty back page. Pages Unlike emails, Print sections can contain multiple pages. Pages are naturally limited by their size and margins. If the content of a section doesn't fit on one page, the overflow goes to the next page. This happens automatically, based on the section's page size and margins; see "Page settings: size, margins and bleed" on the next page.
PAGE 183
When it comes to positioning elements on a page, Guides can be useful, as well as Tables. See "How to position elements" on page 230. Page settings: size, margins and bleed On paper, whether it is real or virtual, content is naturally limited by the page size and margins. These, as well as the bleed, are set per Print section, as follows: l On the Resources pane, right-click a section in the Print context and click Properties.
PAGE 184
1. Import the promotional image or snippet; see "Images" on page 119 and "Snippets" on page 216. 2. Insert the promotional image or snippet in the content. Note l l Only a top-level element (for example, a paragraph that is not inside a table or div) can function as a whitespace element. Do not place the promotional image or snippet inside an absolute positioned box. Whitespacing only works for elements that are part of the text flow, not for absolute-positioned boxes. 3.
PAGE 185
l l l Content page count: This is the total number of pages in the current document that have contents, supplied by the Print section. A page that has a Master Page but no contents, is not included in the Content page count. Sheet number: The current sheet number in the document. A sheet is a physical piece of paper, with two sides (or pages). This is equivalent to half the page number, for example if there are 10 pages, there will be 5 sheets.
PAGE 186
1. Open the style sheet for the Print context: on the Resources pane, expand the Styles folder and double-click context_print_styles.css. 2. Add a CSS rule, like the following: p { widows: 4; orphans: 3 } Per paragraph To change the widow or orphan setting for one paragraph only: 1. Select the paragraph, using the breadcrumbs or the Outline pane (next to the Resources pane). 2. On the Format menu, click Paragraph. 3.
PAGE 187
l In the Breaks group, set the before or after property. l l Before: Sets whether a page break should occur before the element. This is equivalent to the page-break-before property in CSS; see CSS page-break-before property for an explanation of the available options. After: Sets whether a page break should occur after the element. Equivalent to the page-break-after property in CSS; see CSS page-break-after property for an explanation of the available options.
PAGE 188
Master Pages resemble Print sections, and they are edited much the same way, see "Editing a Master Page" below; but they contain a single page and do not have any text flow. Only one Master Page can be applied per page in printed output. When a Print template is created, one master page is added to it automatically. You can add more Master Pages; see "Adding a Master Page" below.
PAGE 189
is good practice to position elements on a Master Page by placing them in a Positioned Box (see "Content elements" on page 72). Keep in mind that a Master Page always remains a single page. Its content cannot overflow to a next page. Content that doesn't fit, will not be displayed. Note Editing the Master Page is optional. One Master Page must always exist in a Print template, but if you don't need it, you can leave it empty.
PAGE 190
Applying a Master Page to a page in a Print section Every page in a print section has a natural position: it can be the first page, the last page, one of the pages in between (a 'middle page'), or a single page. For each of those positions, you can set a different Master Page and Media (see "Media" below). It can even have two master pages, if printing is done on both sides (called duplex printing). To apply Master Pages to specific page positions in a Print section: 1.
PAGE 191
Media can be applied to pages in a Print section, to make them appear as a background to those pages. This ensures that elements added to the Print context will correspond to their correct location on the preprinted media. For further explanation about how to apply Media to different pages, see "Applying Media to a page in a Print section" on page 193. Media will not be printed, unless you want them to; see below.
PAGE 192
1. On the Resources pane, expand the Contexts folder, expand the Media folder, rightclick the Media and click Virtual Stationery. 2. Click the Select Image button to select a PDF image file. 3. Click Resources, Disk or Url, depending on where the image is located. l l l Resources lists the PDF files that are present in the Images folder on the Resources pane. Disk lets you choose an image file that resides in a folder on a hard drive that is accessible from your computer.
PAGE 193
1. On the Resources pane, expand the Contexts folder, expand the Media folder, and right-click the Media. Click Characteristics. 2. Specify the paper's characteristics: l l l l l l l Media Type: The type of paper, such as Plain, Continuous, Envelope, Labels, Stationery, etc. Weight: The intended weight of the media in grammage (g/m2). Front Coating: The pre-process coating applied to the front surface of the media, such as Glossy, High Gloss, Matte, Satin, etc.
PAGE 194
3. If the option Same for all positions is checked, the same Media will be applied to every page in the print section. Uncheck this option. 4. Decide which Media should be linked to each sheet position: click the downward pointing arrow after Media and select a Media. 5. Optionally, decide which Master Page should be linked to each sheet; see "Master Pages" on page 187.
PAGE 195
See "Write your own scripts" below if you are not familiar with how scripts are written. 5. Click Apply, open the tab Preview and browse through the records to see if the script functions as expected. 6. When you click OK, the script will be added to the Scripts pane. Printing virtual stationery Media are not printed, unless you want them to. Printing the virtual stationery is one of the settings in a Job Creation Preset. To have the virtual stationery printed as part of the Print output: 1.
PAGE 196
When Connect generates the actual output – letters, web pages or emails -, it opens a record set and merges it with the template. It takes each record, one by one, and runs all scripts for it (Control Scripts first). All scripts, except Control Scripts, must have a selector. The selector can be text, an HTML element and/or a CSS selector. Running a script starts with looking for pieces of content in the template that match the script's selector.
PAGE 197
l A selector (HTML/CSS): n n n n l HTML elements of a certain type, such as a paragraph:
. In the script Wizard, click Selector and type the HTML tag without the angle brackets: p. HTML elements with a specific CSS class (.green). In the script Wizard, click Selector and type the class name, including the preceding dot: .green. An HTML element with a specific ID (#intro). In the script Wizard, click Selector and type the ID, including the preceding #: #intro.
PAGE 198
Warning When you change an expanded text script and save it, it becomes impossible to edit the script using the Script Wizard again. 2. Write the script. Click Apply from time to time to see if the script works as expected. This will be visible on the Preview tab in the main workspace. Syntax rules Every script in the Designer must follow JavaScript syntax rules. For example, each statement should end with ; and the keywords that can be used, such as var to declare a variable, are JavaScript keywords.
PAGE 199
It does this for each and every customer, because it does not depend on a value from the record that is being merged to the template. Using values from the record in a script To access the record that is being merged to the template when the script runs, use the object record. Suppose you want to display negative amounts in red and positive amounts in green. Assuming that there is an AMOUNT field in your customer data, you could write the following script (with the selector: td.
PAGE 200
The order in which scripts are executed is particularly important when one script produces content that contains a selector for another script. If the other script has already been executed, it will not run again automatically. So, scripts that produce content that contains one or more selectors for other scripts, need to come first. To change the order in which scripts are executed: l Click a script or a folder in the Scripts pane at the bottom. Drag it up or down and drop it.
PAGE 201
Tip It may be helpful to put scripts that have an effect on the same context or section in one folder, because you can set the execution scope of scripts per folder (see: "Execution scope" below). Note Control scripts are always executed first, regardless of where they are in the Scripts pane. They can not be excluded from execution for a specific context or section, using the execution scope of a folder; see "Execution scope" below.
PAGE 202
Enable/disable scripts A disabled script will not run at all when the template is merged with a record set to generate output. When you disable a folder, all scripts in the folder will be disabled. To enable or disable a script or a folder: l On the Scripts pane, right-click the script or the folder and click Disable (if the script or folder was enabled) or Enable (if the script or folder was disabled). Import/export scripts Scripts can be exported - one at a time - for use in other templates.
PAGE 203
Note that scripts that use values of data fields can only be effective when a data file is open. See "Loading data" on page 153. Test for errors Another way to 'test' a script is to take a look at the Scripts pane. Tip Hover over the name of a script in the Scripts pane to see which parts of the template are affected by the script. Icons on the name of scripts in the Scripts pane can show a warning, information or error icon.
PAGE 204
Test for speed issues To measure the time that the execution of scripts will take: l On the Context menu, click Profile scripts. Profiling means running the scripts in the template, to see how fast scripts in the Scripts pane execute. It helps greatly in troubleshooting performance issues caused by scripts. After running the Script Profiler you can see in which sections the script has run: l Hover the mouse over a value in the column Count to see the number of times that the script has run, per section.
PAGE 205
comparatively time consuming. Avoid using such functions in a loop. Note that the times vary slightly per run of the Script Profiler. Run the Script Profiler a number of times and calculate an average from the results, before trying to speed up the execution of a script. Script Profiler settings Number of runs By default, the Script Profiler runs on 1000 instances of all the scripts. To test on a higher or lower number of instances: 1. On the Window menu, click Preferences 2. Click Scripting 3.
PAGE 206
print/email. loadhtml(location) Loads all HTML from the HTML file. locationString containing a path that can be absolute or relative to the section/context. Use: snippets/
PAGE 207
See the Designer API for more information about this function. Loading a snippet, depending on the value of a data field To load a snippet depending on the value of a data field, you have to add a condition to the script. Example The following script evaluates if the value of the LANGUAGE field in the record is ‘En’. If so, the snippet is added to the content. if (record.fields.LANGUAGE == ‘En’) { results.loadhtml(‘snippets/nameofthesnippet.
PAGE 208
that container an ID, for example:
This is text for English customers.
), but not the container itself (
PAGE 209
For examples and for more uses of Control Scripts, see the sample scripts in the Control Script API: "Sample scripts" on page 66. Tip New Control Scripts added to the template contain a few examples. For more examples see "Sample scripts" on page 66. Adding a Control Script To add a Control Script: 1. On the Scripts pane at the bottom left, click the black triangle on the New button and click New Control Script. A new script appears in the list. 2. Double-click the new script to open it.
PAGE 210
3. Section C page 2 4. Section D page 1 Note that even if a section is not enabled, its restartPageNumber flag is still taken into account for composing the page number sequences. So, if the restartPageNumber flags are set as follows: 1. 2. 3. 4. Section A (1 page) restartPageNumber = true Section B (2 pages) restartPageNumber = false Section C (3 pages) restartPageNumber = true, enabled = false Section D (4 pages) restartPageNumber = false the page numbering in the output will be: 1. Section A page 1 2.
PAGE 211
Example 1: no parts defined Assume there are three Print sections: sections A, B and C. When generating Email output with the Print context as attachment, all three Print sections will be put together in one file and attached to the email. Example 2: 2 parts Assume there are three Print sections: sections A, B and C. In a Control Script a part name is defined for section C: var section = merge.template.contexts.PRINT.sections['Section C']; section.
PAGE 212
After that, the background can be positioned, setting the section's background.position to ABSOLUTE or to FIT_TO_MEDIA. For examples, see the Control Script API: "Sample scripts" on page 66. Sections Sections are parts of one of the contexts in a template: Print or Email. They contain the main text flow for the contents. In each of the contexts there can be multiple sections. A Print context, for example, may consist of two sections: a covering letter and a policy.
PAGE 213
1. Open the section that you want to copy and go to the Source tab in the workspace. 2. Copy the contents of the Source tab (press Ctrl+A to select everything and then Ctrl+C to copy the selection). 3. Add a new section (see Adding a section). 4. Go to the Source tab and paste the contents of the other section here (press Ctrl+V). 5. When copying a section to another template, add the related source files, such as images, to the other template as well.
PAGE 214
To change the properties for a section: l On the Resources pane, expand the Contexts folder, expand the folder of the respective context, right-click the name of the section, and then click one of the options. Applying a style sheet to a section In order for a style sheet to be applied to a specific section, it needs to be included in that section. There are two ways to do this. Drag & drop a style sheet 1. Click and hold the mouse button on the style sheet on the Resources pane. 2.
PAGE 215
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. The sections are added to the output in the order in which they appear on the Resources pane. See "Generating Print output" on page 138. In email output, only one section can be executed at a time. The section that will be output is the section that has been set as the 'default'.
PAGE 216
Skin/Formats/CrossReferencePrintFormat("Email attachments" on page 1)." on page 1) to learn how to generate Print documents or Email. Snippets A snippet is a small, ready-to-use piece of content in a file. Snippets can be re-used within the same template, in all contexts and sections. They can contain any contents that a section can have, such as text, images, variable data, dynamic tables, etc.
PAGE 217
It is also possible, and often useful, to insert a snippet or part of it, using a script. See "Loading a snippet via a script" on page 205. Creating a snippet To turn a parts of a letter or email into a snippet for reuse in the content of a template: 1. Select the part that should be saved in a snippet. 2. Right-click the selection, point to Snippet and click Create. 3. Right-click the new snippet on the Resources pane in the Snippets folder and rename it.
PAGE 218
Whether applied through style sheets or through local formatting, behind the scenes all layout properties in the Designer are CSS properties. When you format an element locally, an inline style rule is added to the element. Note that where local formatting conflicts with a formatting rule for the same element in one of the style sheets, the local formatting rule gets priority; the rule in the style sheet will be ignored.
PAGE 219
The locale setting influences how dates, numbers and amounts of money are displayed; see "Locale" on page 240. Styling templates with CSS files The Layout toolbar and the Format menu offer many possibilities to style every piece of a template. However, styling every single element, one after another, is a lot of work and, more importantly, can result in a template with a messy mix of styles that isn’t easy to maintain and lacks consistent design.
PAGE 220
On this tab you can view and edit the content of the template in the form of plain text with HTML tags (note the angle brackets: <>). You may add and edit the text and the HTML tags, classes, ID’s and other attributes. To learn more about HTML, see for example https://developer.mozilla.org/enUS/docs/Web/Guide/HTML/Introduction and http://www.w3schools.com/html/default.asp. Many video courses and hands-on courses about HTML (and CSS) are offered on the Internet as well, some for free.
PAGE 221
Tip To export a CSS file from your template, drag or copy/paste it out of the Stylesheets folder to a folder on the local hard drive. Note The order in which style sheets are executed, can affect the actual output. This sequence can be set per section; see "Determining the order in which style sheets are read" on page 226. Using a remote style sheet A remote style sheet is not located within your template but is rather hosted on an external web server (generally called a CDN).
PAGE 222
Styling your templates with CSS files Note Email clients do not read CSS files and some even remove a