Create PDF files using iText and apache speed template (.vm)

What is the general workflow for creating a PDF file using iText and the Apache Velocity (.vm) speed template file in Java?

I am interested in knowing steps like: parse template file, putting a Java object in context and the steps that you need to follow to create pdf, etc.

I know this is a very simple question. But I can not find a single example of this type on the Internet. I found XDocReport , but I am also interested in finding out other alternatives.

Please help me with some sample project link, or at least steps to get started.

+3
source share
3 answers

PDF iText Apache Velocity (.vm) Java , :

  • PDF - ,
  • Velocity .

, Velocity PDF.

XDocReport docx/odt docx/odt, Velocity/Freemarker Java. docx/odt pdf/xhtml.

, docx/odt - zip, XML-. docx, /document.xml. , MS Word. word/document.xml - , Velocity .

XDocReport PDF docx, Velocity:

  • docx. , docx xml ( ). , /document.xml xml .
  • Loop xml, Java. , word/document.xml Java, Velocity, /document.xml .
  • docx, .

docx ().

, XDocReport docx-to-pdf Apache POI iText. XDocReport docx pdf:

  • docx POI Apache
  • POI (XWPFParagraph ..) iText (iText Paragraph).

, XDocReport , .

+4

, . , PDF .

  • HTML , Apache Velocity (.vm).
  • com.itextpdf.text.html.simpleparser.HTMLWorker () / HTML PDF .
  • , com.itextpdf.text.pdf.PdfCopy.PageStamp (, , , ..) PDF.

com.itextpdf.tool.xml.XMLWorker HTML ( ..)

+4

First we use the freemarker template to generate the html file, and then render the html into a pdf file using IItextRender. Finally, we can view the pdf file in the browser, there are some very useful javascript tools called pdfjs. Perhaps you can try.

0
source

All Articles