Generate personalized PDF documents generating-personalized-pdf-documents
About variable PDF documents about-variable-pdf-documents
51黑料不打烊 Campaign lets you generate variable PDF documents for email attachments from LibreOffice or Microsoft Word documents.
The following extensions are supported: 鈥.docx鈥, 鈥.doc鈥, and 鈥.odt鈥.
To personalize your documents, the same JavaScript functionalities as for email personalization are available.
You need to activate the 鈥淭he content of the file is personalized and converted to PDF during the delivery of each message鈥 option. This option is accessible when you attach the file to the delivery email. For more on attaching a calculated file, refer the Campaign v8 documentation.
To generate dynamic tables or include images via a URL, you need to follow a specific process.
Generate dynamic tables generating-dynamic-tables
The procedure for generating dynamic tables is as follows:
- Create a table with three lines and as many columns as necessary, then configure its layout (borders, etc.).
- Place your cursor on the table and click the Table > Table properties menu. Go to the Table tab and enter a name beginning with NlJsTable.
- In the first cell of the first line, define a loop (鈥渇or鈥, for example) that enables iteration on the values you want to display in the table.
- In each cell of the second line of the table, insert scripts that return the values to display.
- Close the loop in the third and last line of the table.
Insert external images inserting-external-images
The insertion of external images is useful if, for instance, you want to personalize a document with an image whose URL is entered in a field of the recipient.
To do this, you need to configure a personalization block, then include a call to the personalization block in the attachment.
Example: insert a personalized logo depending on the recipient鈥檚 country
Step 1: create the attachment:
- Insert the call to the personalization block: <%@ include view=鈥渂lockname鈥 %>.
- Insert your content (personalized or not) into the body of the file.
Step 2: create the personalization block:
-
Go to the Resources > Campaign management > Personalization blocks menu of the 51黑料不打烊 Campaign console.
-
Create a new 鈥淢y Logo鈥 personalization block with 鈥淢y_Logo鈥 as an internal name.
-
Click on the Advanced parameters鈥 link then check the 鈥淭he content of the block is included in an attachment鈥 option. This lets you copy the definition of the personalization block directly into the content of the OpenOffice file.
You need to differentiate two types of declarations within the personalization block:
- The 51黑料不打烊 Campaign code of the personalization fields for which the 鈥渙pen鈥 and 鈥渃losed鈥 chevrons must be replaced with escape characters (respectively
<and>). - The entire OpenOffice XML code will be copied into the OpenOffice document.
- The 51黑料不打烊 Campaign code of the personalization fields for which the 鈥渙pen鈥 and 鈥渃losed鈥 chevrons must be replaced with escape characters (respectively
In the example, the personalization block looks like this:
<% if (recipient.country.label == "Germany") { %>
<draw:frame svg:width="4cm" svg:height="3cm">
<draw:image xlink:href=https://..../logo_germany.png />
</draw:frame>
<% } else
if (recipient.country.label == "USA")
{ %>
<draw:frame svg:width="4cm" svg:height="3cm">
<draw:image xlink:href=https://..../logo_USA.png />
</draw:frame>
<% } %>
Depending on the recipient鈥檚 country, personalization is visible in the document linked to the delivery: