Index for document generation

We have to generate a report with more than 10 pages with the document generator. We also have to put a page index in front of the document. Anybody done this with Mendix?
3 answers

I've done this by creating a domain model with entities representing chapters. The chapters are related to a TOC entity and contain a page number.

Create a TOC entity

Create chapter 1, calculate number of pages in chapter 1 and create an entity called Chapter with a index set to 1 and a pagenumber set to x and association to TOC

Create chapter 2 etc..

Create a document template which creates a TOC, and create a document template for the chapters. Create all documents and put them in a temporary list. At the end create a java action which combines all the PDF's to one and remove all entities from the temp list (otherwise they will stay on disk!)


We've implemented a fully automatic TOC generator in the mean while.

It searches the document for predefined headings and paragraphs and generates a TOC out of it which is merged back into the main document.

If anybody is interested feel free to contact me. We will add it to the app store soon.


Herbert : Create a java action which has a system.Filedocument as input and an integer as output. Deploy for eclipse (F6) Edit the generated java action by adding the code below between the //BEGIN USER CODE and //END USER CODE

Integer pages = 0; InputStream pdf = Core.getFileDocumentContent(getContext(), __File); try { PdfReader pdfReader = new PdfReader(pdf); pages = pdfReader.getNumberOfPages(); } finally { pdf.close(); } return pages.longValue();