There are several cases where it makes sens to generate a rendition of a Nuxeo Document.
- you store product related information in Nuxeo
=> you want to generate a Product description file in .doc or .pdf
(with most important meta-data + version and history info + picture)
- you manage mails in Nuxeo
=> you want to generate the response letter
(with logo, custom header ...)
- you store Specifications / Code audit / Benchmark results in Nuxeo
=> you want to generate the delivrable report
(with Cover page, Index, and data aggregated from several documents ...)
We already have several features like this in Nuxeo Platform :
- generate PDF / Excel view via JSF / Seam / iText
=> but template is not easy to update for users
=> page layout must remain simple
- generate BIRT reports
=> creating a BIRT report design can be complicated
=> the goal of BIRT is more data aggregation and BI than rendering
The main constraints has to be the template model.
In a lot of cases, users need to be able to modify the template, but :
- contributing XML / Layouts is either :
- not flexible enough
- not powerful enough
- writting complete JSF / Freemarker template seen complicated
Truth is that most people want to use Office tools (like MSO or OpenOffice) to do that.
As much as possible we need to rely on "standard" like OpenDocument and DocX.
It's easier to use XML based generation and it avoids relying on a running OpenOffice server.
We have already done some successful tests with DocX and JODReport.
The approach of JODReport, using Freemarker to generate OpenDocument seems like the right one.
On the Nuxeo level we have :
- a TemplateDocument : this documents holds the template file as well as some default parameters
- a TemplateBasedDocument : this is a standard Nuxeo Document that is associated with a Template and can then support rendition
In the prototype the logic is bound to Facets so that you can create a rendition from potentially any kind of Document (this may require to store the resulting rendering in a field associated to the facet wich is not the case for now).
- Template file creation
- create an office document via OpenOffice or MSOffice
- From within the editor program I mark some fields or section to be merge/replaced
(basically I tag the Document)
- Create the Template document in Nuxeo
- Inside Nuxeo I create a new Template Document and upload my template file
- Nuxeo extract the structure from the template file and gives me a listing of the fields
- I can define types and binding for each fields ( direct value, or XPath to document properties)
- I can add fields if needed
- Create a Template Based document in Nuxeo
- For selected Document types when I create them I can select the associated template
- If some parameters are still unset at template level the user will be prompted to enter them