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:
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 ‚|‘:
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.
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‘):
This ButtonAction needs to be assigned to our submit button on the PURL:
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.
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!