Convert pdf Using java library

I am ready to convert xhtml files to pdf / format or pdf files to pdf / a format. Can someone suggest some java library that I can use. thank you

I will make my example more specific

I have a simple html file xyz.html

<html><body> hello <br> <font style = "Helvetica">hello</font> <br> </body></html> 

java code:

 Document document = new Document(PageSize.A4); FileOutputStream fout = new FileOutputStream(pdffile); PdfWriter pdfWriter = PdfWriter.getInstance(document, fout); pdfWriter.setPDFXConformance(PdfWriter.PDFA1B); FileReader fr = new FileReader(xyz.html); document.open(); HashMap<String, Object> Provider = new HashMap<String, Object>(); DefaultFontProvider def = new Provider.put(HTMLWorker.FONT_PROVIDER, def); HTMLWorker htmlWorker = new HTMLWorker(document); htmlWorker.setProviders(Provider); htmlWorker.parse(fr); 

I get the error com.itextpdf.text.pdf.PdfXConformanceException: all fonts must be embedded. This is not: Helvetica

+4
source share
4 answers
+2
source

Check out the iText library, which supports both Java and .net
http://itextpdf.com/

A few examples in the link below:
http://itextpdf.com/book/examples.php
http://www.rgagnon.com/javadetails/java-html-to-pdf-using-itext.html

It is proprietary, but It is truly an intelligent corporate library and has good customer support.

+1
source

Consider the Apache FOP project , it supports the conversion of xml files to pdf files.

0
source

I'm working on the expected behavior, and we developed a SaaS application called DocRaptor that converts HTML to PDF using Prince XML as our rendering engine. DocRaptor uses HTTP POST requests to create PDF files and can be used with Java.

Here is a link to our Java example:

Java DocRaptor Example

And the link to the DocRaptor homepage:

DocRaptor

DocRaptor is a subscription-based service, but our free plan allows you to create up to 5 documents per month, and we do not insert watermarks or limit the size of free documents.

0
source

All Articles