Skip to content Skip to sidebar Skip to footer

Html To Pdf Using Itext Xmlworker

Document document = new Document(PageSize.A4, ml, mr, mt, mb); PdfWriter writer=PdfWriter.getInstance(document, response.getOutputStream()); String sc_na=request.getParame

Solution 1:

For Html to PDF, use Flying Saucer: http://code.google.com/p/flying-saucer/

It uses iText 2.0.8 and it respects a CSS. It is as much code as:

 org.w3c.dom.Documentdoc= . . .
 ITextRendererrenderer=newITextRenderer();
 renderer.setDocument(doc, null);

 renderer.layout();
 renderer.createPDF(out);

Make sure your XHTML links to a reachable CSS, e.g.

 <linktype="text/css" href="file://. . ./pdf.css" media="print"/>

Post a Comment for "Html To Pdf Using Itext Xmlworker"