0

In Java Project, i would like to use a Freemarker or something similar to it (Quick start guide), but to generate a PDF file (textual), with IText for example.

Of cource, the workflow could be like that:

Template (Freemarker) -> Text (IText) -> PDF

...but I feel it is kind of a naive approach. I want to have in the PDF some formattings, tables, etc.

Anyone knows how to design it properly?

CherryDT
  • 25,571
  • 5
  • 49
  • 74
J J
  • 146
  • 2
  • 11

1 Answers1

1

As PDF is a binary format, the best seems to generate some standard text format for which there exists a PDF conversion.

Texts --[FreeMarker]--> HTML or      --[HTML-to-iText]--> PDF
                        DocBook XML

This also allows validation of the FreeMarker templates.

Joop Eggen
  • 107,315
  • 7
  • 83
  • 138
  • thanks! can you link me something the HTML or XML to I Text thing please? – J J May 12 '16 at 12:16
  • A search "java html to pdf" yielded http://stackoverflow.com/questions/633780/converting-html-files-to-pdf but I would do a bit of research to current converters. There are many HTML versions, tricky things like images. DocBook XML, especially the more tractable new Simple DocBook XML is might be less open-ended (=more complete features) than HTML; they can do PDF generation, with niceties as page footers. Other formats exist with PDF generation, **epub** I believe. – Joop Eggen May 12 '16 at 12:22