Creating Documents with DirectSmile Crossmedia totally dynamical

11. März 2014

Today I would like to blog about creating dynamic documents with the new DirectSmile Crossmedia V6.

When talking about a ‚dynamic document‘ I mean a document whose content will be constructed on a dynamic way. For this blog I will allow the user to pick several chapters from a list and will get a PDF in return. So the final document will need to be build based on the users selection.

To achieve my goal I will first need a PURL which allows my user to pick several available chapters. Thisfor I will need the ‚MultiSelect‘ item from the extension items library.

So my basic PURL will require a firstname, a lastname and a selection of several chapters:

Simple setup for our PURL

Simple setup for our PURL

Creating a dynamic document which will be rendered as PDF requires a XML which we call DocML. This is a language which allows you to create documents just with a XML syntax. Please see the manual (Document and Composition XML Commands) for more details about DocML.

The multiple selection will be stored as a stringlist with pipes as delimeter. Next we will need to create a new ’scripted data relation‘ to generate the DocML which will generate our document based on the users selection.

So just add a new scripted datarelation and edit it to read from the current table row and split the string by ‚|‘:

A first setup for our data relation.

A first setup for our data relation.

As we now have all informations needed to set up our document we will start creating our XML. We will simply create new pages for every valid entry in our splitted string which contains only a single image referencing to a PDF file containing the selected chapter which I’ve uploaded to my template images before.

In case your chapters are longer than single pages you will need another database containing individual informations about each chapter so you can regard these in your JavaScript. But for our small example we simply assume that each chapter only consists of one single page.

Final DataRelation with full DocML result.

Final DataRelation with full DocML result.

Also we need a ButtonAction defined inside our DataRelation so that we can write the DocML to our database. Please recognize that I’ve also added a second condition (Mode ===‘ ButtonAction‘):

In the head section of the DataRelation we define a ButtonAction to trigger the write-2-db from outside.

In the head section of the DataRelation we define a ButtonAction to trigger the write-2-db from outside.

This ButtonAction needs to be assigned to our submit button on the PURL:

Assign the ButtonAction from the DataRelation to the submit button.

Assign the ButtonAction from the DataRelation to the submit button.

So after that we will only need to create a dummy document which needs to be web editable – this will allow us to render this document on our page but with our DocML as payload to overwrite the content with our dynamic one.

Configure the dummy document to pick the DocML from the correct database column

Configure the dummy document to pick the DocML from the correct database column

And finally we have all we want. We can now use this document to be rendered on a PURL, sent to the workflow or attached to an e-mail.

If you want to try this on your own please use the attached ZIP file to import this example campaign.

Finally to say: Many thanks to my dear colleague Wolfgang – without his work this article would not have been possible!

Werbeanzeigen