OverviewThe XSL stylesheet is what is used to layout the design of the data onto the page. It reads an XML file, and transforms it using the XSL with the result being a PDF document.
In the past, I have used this flowchart that I made. This post will focus on the stylesheet creation in the big gray box.
page links to companies that make these tools. The prices for these range from $400 to ~$1000 for a single user license. There is also a inexpensive solution to use which is called FO Designer which is about $60. We went with FO Designer, with the thinking being that this tools just does what we want without paying for features we wouldn't use. I will save my commentary of it for the opinions sections at the end.
The FO Designer works this way. You visually layout on the screen your form, then you push a button to generate the XSL-FO. I would then copy the generated FO into a stylesheet within Domino Designer. I would then refresh my page, and test the PDF. The tool had a way to test PDFs but I needed it to work within Domino, and I didn't consider the tools PDF generation a true test.
The Opinion SectionThis section is named such so I can tell you what I really think. Here are the major obstacles that I faced.
1) FO Designer might have been great in the year 2000, but it is inadequate now. I regret thinking that I could make it work. I wish I pushed for one of the modern higher $$$ options. It doesn't seem to support tables, and vertical lines don't render. It has no undo, and is very clunky to use. When you create an element and set the Xpath to "absolute", and then copy and paste that element it resets to "relative" which causes the PDF creation to fail in Domino.
2) PDF creation in Domino is an all or nothing proposition. If there is any part of the code not exactly 100% perfect then the PDF creation will fail, and you won't know why. I found myself having to examine the generated XSL in sublime text prior to copying into my application.
The Recommendation SectionIf you find yourself needing to create PDF's this way then I recommend the following.
1) Choose one a different tool than FO Designer. It will cost you or your company more money, but it will save a lot of frustration. I can't offer a recommendation as I haven't tried the others.
2) Test your work NOT in Domino, but using web based tools like this one http://www.utilities-online.info/foprender/#.UsxyvPRDuSo This tool will give you a hint of what is wrong, when something is wrong, as opposed to just not working. Once it looks right here, then you can copy it into Domino and test it there.
3) The XSL will transform a single XML file. If you have multiple document that need to be combined into a single XML file, I found the following to be a quick and easy way to do it.
- In your java method that generated the XML, do a lookup and get a handle to the related documents
- Loop through the related documents, and copy the values you want on the PDF onto the main document
- Once the items are copied to the main document then run the generateXML() method
- Don't save the main document with all the new values on it, you want the PDF to only have the latest data each time you create it.
As for me, we are putting this part of the project on hold. I hope we come back to it, as I have invested a lot of time and effort in getting this far. In another sense I am relieved to move on.