Java iText Convert HTML to PDF Example Tutorial

In this post, we will provide a basic example that explains how to convert a HTML document to a PDF file using the Java iText library. Converting a HTM file to PDF document would be a simple task if you have all the required libraries with you. In addition to using iText, we will use some more APIs to achieve this conversion. I'm fascinated towards an API, popularly known as Flying Saucer. I will be using R8 version of this API and you can download the additional JAR files from the following location. You will be able to appreciate the conversion process as this library makes the transformation of HTML to PDF a fairly quick task with very minimal code.  It internally uses iText and so I believe you can still retain your iText functionality and build the conversion on top of this. We will see some examples for this as we move on.

To begin converting HTML to PDF using iText, make sure that you have the following JAR files in your classpath after you have downloaded the XML/XHTML and CSS renderer. The files I'm after are listed below (along with iText);

1) core-renderer.jar
2) core-renderer-minimal.jar
3) xml-apis-xerces-2.9.1.jar

We can get started now. The step by step guide to convert HTML to PDF is provided below;

Step-1: Prepare a HTML Hello World file for testing. (You can very well use your HTML code instead of this. More advanced examples later). If you are looking for something quick, you can use the HTML provided below;
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Example To Convert HTML to PDF in Java iText</title>
        <style type="text/css"> b { color: blue; } </style>
    </head>
    <body>        
            <b>Hello World</b>
            We have successfully transformed a HTML File to PDF document in Java!!
     <br/>
     <b>This solution and example works </b>
    </body>
</html>

Step-2: We begin by defining an input HTML file and convert it into an URL. We also define an output stream where the PDF document would be produced. Refer to the code below that explains how to do this in Java;
        String File_To_Convert = "test.htm";
        String url = new File(File_To_Convert).toURI().toURL().toString();
        System.out.println(""+url);
        String HTML_TO_PDF = "ConvertedFile.pdf";
        OutputStream os = new FileOutputStream(HTML_TO_PDF);       

Step-3:We now use the iTextRenderer class defined in org.xhtmlrenderer.pdf.ITextRenderer and use the "createPDF" method of this class to generate the PDF. Now, the iTextRenderer class needs to know the location to pick up the incoming HTM file. This is provided by using the "setDocument" method of the class. Just four lines of code and you get the new PDF file.
        ITextRenderer renderer = new ITextRenderer();
        renderer.setDocument(url);      
        renderer.layout();
        renderer.createPDF(os);        
        os.close();
Step-4: While creating the PDF we can get either IOException (if input file could not be located) or DocumentException and these needs to be caught.

The complete code to produce a PDF from a HTML document by converting the HTML to PDF using Java iText is provided below;
import java.io.*;
import com.lowagie.text.DocumentException;
import org.xhtmlrenderer.pdf.ITextRenderer;

public class FirstDoc {
    
    public static void main(String[] args) 
            throws IOException, DocumentException {
        String File_To_Convert = "test.htm";
        String url = new File(File_To_Convert).toURI().toURL().toString();
        System.out.println(""+url);
        String HTML_TO_PDF = "ConvertedFile.pdf";
        OutputStream os = new FileOutputStream(HTML_TO_PDF);       
        ITextRenderer renderer = new ITextRenderer();
        renderer.setDocument(url);      
        renderer.layout();
        renderer.createPDF(os);        
        os.close();
    }
}
This basic example tutorial produces a PDF as shown in the image below;
HTML to PDF using Java
HTML to PDF in Java iText

45 comments:

  1. Hello, I tried your example and got the following exception when converting my html document to pdf .

    ERROR: 'The element type "br" must be terminated by the matching end-tag "
    ".'
    Exception in thread "main" org.xhtmlrenderer.util.XRRuntimeException: Can't load
    the XML resource (using TRaX transformer). org.xml.sax.SAXParseException: The e
    lement type "br" must be terminated by the matching end-tag "".
    at org.xhtmlrenderer.resource.XMLResource$XMLResourceBuilder.createXMLRe
    source(XMLResource.java:191)
    at org.xhtmlrenderer.resource.XMLResource.load(XMLResource.java:71)
    at org.xhtmlrenderer.swing.NaiveUserAgent.getXMLResource(NaiveUserAgent.
    java:211)
    at org.xhtmlrenderer.pdf.ITextRenderer.loadDocument(ITextRenderer.java:1
    34)
    at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:13
    8)
    at FirstDoc.main(FirstDoc.java:16)
    Caused by: javax.xml.transform.TransformerException: org.xml.sax.SAXParseExcepti
    on: The element type "br" must be terminated by the matching end-tag "".
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transfor
    m(TransformerImpl.java:719)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transfor
    m(TransformerImpl.java:313)
    at org.xhtmlrenderer.resource.XMLResource$XMLResourceBuilder.createXMLRe
    source(XMLResource.java:189)
    ... 5 more
    Caused by: org.xml.sax.SAXParseException: The element type "br" must be terminat
    ed by the matching end-tag "".
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Ab
    stractSAXParser.java:1231)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transfor
    mIdentity(TransformerImpl.java:636)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transfor
    m(TransformerImpl.java:707)
    ... 7 more

    can you help?

    ReplyDelete
  2. Hi,

    You are getting this exception because you are using a <br> tag in your HTML that is not closed. Use </br> or <br/> and try it again. It should work.

    ReplyDelete
  3. Does anyone know if you can have the HTML input be a page of the format jobAppView.do?id=42 ? I have an online job application form that I need to capture to a pdf file....

    Thanks,
    -Terri

    ReplyDelete
  4. @Terri

    When you try this example, can you tell me the exception you are getting on the screen?

    ReplyDelete
  5. which jar file used for ITextRenderer renderer = new ;
    renderer.setDocument(url);
    renderer.layout();
    renderer.createPDF(os);

    ReplyDelete
  6. 1) core-renderer.jar
    2) core-renderer-minimal.jar
    3) xml-apis-xerces-2.9.1.jar

    are the files..

    ReplyDelete
  7. ERRO: 'White spaces are required between publicId and systemId.'
    plumbing.exception WARNING:: Unhandled exception. Can't load the XML resource (using TRaX transformer). org.xml.sax.SAXParseException: White spaces are required between publicId and systemId.
    Exception in thread "main" org.xhtmlrenderer.util.XRRuntimeException: Can't load the XML resource (using TRaX transformer). org.xml.sax.SAXParseException: White spaces are required between publicId and systemId.
    at org.xhtmlrenderer.resource.XMLResource$XMLResourceBuilder.createXMLResource(XMLResource.java:191)
    at org.xhtmlrenderer.resource.XMLResource.load(XMLResource.java:71)
    at org.xhtmlrenderer.swing.NaiveUserAgent.getXMLResource(NaiveUserAgent.java:118)
    at org.xhtmlrenderer.pdf.ITextRenderer.loadDocument(ITextRenderer.java:98)
    at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:102)
    at flyingsaucerpdf.TesteHTML.main(TesteHTML.java:21)
    Caused by: javax.xml.transform.TransformerException: org.xml.sax.SAXParseException: White spaces are required between publicId and systemId.
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
    at org.xhtmlrenderer.resource.XMLResource$XMLResourceBuilder.createXMLResource(XMLResource.java:189)
    ... 5 more
    Caused by: org.xml.sax.SAXParseException: White spaces are required between publicId and systemId.
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(Unknown Source)
    ... 8 more


    Can you help?

    ReplyDelete
  8. @Luiz,

    Can you post your HTML / Java code? Also,the version of Jar files you used?

    ReplyDelete
  9. Bom dia . @YellowRose
    descobri a causo do problema.
    São os acentos em algumas palavras.
    Você tem alguma sugestão para corrigir isto?
    meu email é luiz641@hotmail.com
    qualquer coisa me manda email direto.

    ReplyDelete
  10. @Luiz, can you post one simple example HTML so that I can try and fix it for you?

    ReplyDelete
  11. Hello,

    I tried your example and it works great on a windows pc.
    Now I want to run it on a linux 64-bit machine with java 64 and it crashes with the following exception.

    java.lang.NoSuchMethodError: com.lowagie.text.pdf.BaseFont.getCharBBox(C)

    Do you have an idea how to solve this problem?

    Thanks in advance.

    LStrike

    ReplyDelete
  12. @LStrike,

    Can you post your Java code and the HTML you used for conversion? I will have a look.

    ReplyDelete
  13. hello,
    If i declare the style in the starting of html.it is not getting reflected in my PDF.what should I need to do inorder to generate the PDF with all stylings

    Apurva

    ReplyDelete
  14. @Apurva, please post your HTML code.

    ReplyDelete
  15. Hi I am getting following error. Could you put me in right direction what I am I doing wrong?

    plumbing.load.xml-entities WARNING:: Could not open XML catalog from URI 'resources/schema/xhtml/catalog-xhtml-1.0.xml'
    plumbing.load.xml-entities WARNING:: Could not open XML catalog from URI 'resources/schema/xhtml/catalog-xhtml-1.1.xml'
    plumbing.load.xml-entities WARNING:: Could not open XML catalog from URI 'resources/schema/docbook/catalog-docbook.xml'
    FATAL ERROR: 'java.io.IOException: Stream closed'
    :Stream closed
    plumbing.load INFO:: Loaded document in ~16ms
    plumbing.exception WARNING:: Could not parse default stylesheet
    java.lang.NullPointerException
    at org.xhtmlrenderer.simple.extend.XhtmlCssOnlyNamespaceHandler.findFirstChild(XhtmlCssOnlyNamespaceHandler.java:241)
    at org.xhtmlrenderer.simple.extend.XhtmlCssOnlyNamespaceHandler.getStylesheets(XhtmlCssOnlyNamespaceHandler.java:331)
    at org.xhtmlrenderer.context.StyleReference.getStylesheets(StyleReference.java:247)
    at org.xhtmlrenderer.context.StyleReference.setDocumentContext(StyleReference.java:104)
    at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:130)
    at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:106)
    at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:102)
    at JavaAgent.NotesMain(Unknown Source)
    at lotus.domino.AgentBase.runNotes(Unknown Source)
    at lotus.domino.NotesThread.run(Unknown Source)

    ReplyDelete
  16. @Vinay,can you post your HTML code?

    ReplyDelete
  17. hi, i had tried ur example but it is showing the following exception, can u help me out..

    Exception in thread "main" java.lang.NoSuchMethodError: com.lowagie.text.Rectangle.getHeight()F
    at org.xhtmlrenderer.pdf.ITextRenderer.writePDF(ITextRenderer.java:339)
    at org.xhtmlrenderer.pdf.ITextRenderer.createPDF(ITextRenderer.java:315)
    at org.xhtmlrenderer.pdf.ITextRenderer.createPDF(ITextRenderer.java:246)
    at FirstDoc.main(FirstDoc.java:18)

    ReplyDelete
  18. hi, i had tried ur example and it worked, but for strict HTML(i mean XHTML). i want to develop an application(using java) which converts the webpage to an pdf document(like how www.web2pdfconverter.com does), i tried ur way but the html code of the web pages is not strict HTML, can u help me out..? Thanks in advance.

    ReplyDelete
  19. @Ajay,

    Did you use the same HTML code that I have provided? What version of JAR files you used?

    ReplyDelete
  20. when i define styles in the starting of html, styles are not reflecting.. Am not able to post my html here. Its not allowed.

    ReplyDelete
  21. you need to do some tweaks to support stylesheet..I'm working on this. Connect to this site and you will get an update shortly.

    ReplyDelete
  22. @Ajay Maybe you can try to convert from HTML to XHTML using jTidy and then use iText with the XHTML generated.

    ReplyDelete
  23. i m getting Exception Can't load the XML resource (using TRaX transformer). java.io.IOException: Stream closed

    ReplyDelete
  24. Can't load the XML resource (using TRaX transformer). java.io.IOException: Stream closed

    ReplyDelete
  25. @Naval, post your java version, version of jar files and code. I will have a look.

    ReplyDelete
  26. now i have again try and using jdk 1.4 and i have download all the Jar file from your provided Location and getting the problem "Can't load the XML resource (using TRaX transformer). java.io.IOException: Stream closed"

    ReplyDelete
  27. Does your HTML file reside in the same directory as your java code? Can you post the code please?

    ReplyDelete
  28. I have been looking into this and it looks like you must have a valid HTML.

    usually there are rare cases where you have a 100% valid html..

    so iText needs to be improved much more to really work in "real-life" production quality applications.

    for eg. if you try to use http://www.chinadaily.com/
    it will fail with bunch of exceptions similar to all of above exception.

    here is the I text official demo page which also fails to convert!
    http://demo.itextsupport.com/xmlworker/

    ps: It says provide feed back, but didn't find actual link to provide one!

    ReplyDelete
  29. HI.. I am Manju Vani

    I tried ur exmaple its giving the out put but it is giving the following error plz help me in resolving this error.

    java.io.IOException: Stream closed
    at java.io.BufferedInputStream.getInIfOpen(Unknown Source)
    at java.io.BufferedInputStream.read1(Unknown Source)
    at java.io.BufferedInputStream.read(Unknown Source)
    at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
    at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
    at sun.nio.cs.StreamDecoder.read(Unknown Source)
    at java.io.InputStreamReader.read(Unknown Source)
    at org.xhtmlrenderer.css.parser.Lexer.zzRefill(Lexer.java:1634)
    at org.xhtmlrenderer.css.parser.Lexer.yylex(Lexer.java:1865)
    at org.xhtmlrenderer.css.parser.CSSParser.next(CSSParser.java:1778)
    at org.xhtmlrenderer.css.parser.CSSParser.la(CSSParser.java:1790)
    at org.xhtmlrenderer.css.parser.CSSParser.stylesheet(CSSParser.java:157)
    at org.xhtmlrenderer.css.parser.CSSParser.parseStylesheet(CSSParser.java:87)
    at org.xhtmlrenderer.context.StylesheetFactoryImpl.parse(StylesheetFactoryImpl.java:78)
    at org.xhtmlrenderer.context.StylesheetFactoryImpl.parse(StylesheetFactoryImpl.java:95)
    at org.xhtmlrenderer.context.StylesheetFactoryImpl.getStylesheet(StylesheetFactoryImpl.java:174)
    at org.xhtmlrenderer.context.StyleReference.readAndParseAll(StyleReference.java:123)
    at org.xhtmlrenderer.context.StyleReference.setDocumentContext(StyleReference.java:107)
    at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:175)
    at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:142)
    at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:138)

    ReplyDelete
  30. Hello, I tried your example and got the following exception when converting my html document to pdf .

    Exception in thread "main" java.lang.NoSuchMethodError: com.lowagie.text.pdf.BaseFont.getCharBBox(I)[I
    at org.xhtmlrenderer.pdf.ITextFontResolver$FontDescription.setMetricDefaults(ITextFontResolver.java:696)
    at org.xhtmlrenderer.pdf.ITextFontResolver$FontDescription.(ITextFontResolver.java:627)
    at org.xhtmlrenderer.pdf.ITextFontResolver.addCourier(ITextFontResolver.java:427)
    at org.xhtmlrenderer.pdf.ITextFontResolver.createInitialFontMap(ITextFontResolver.java:407)
    at org.xhtmlrenderer.pdf.ITextFontResolver.(ITextFontResolver.java:52)
    at org.xhtmlrenderer.pdf.ITextRenderer.(ITextRenderer.java:115)
    at org.xhtmlrenderer.pdf.ITextRenderer.(ITextRenderer.java:102)
    at FirstDoc.main(FirstDoc.java:14)


    I am Using following Jars

    1. core-renderer.jar
    2. core-renderer-R8-final.jar
    3. core-renderer-R8pre2-sources.jar
    4. flyingsaucer-renderer.jar
    5. itext-2.0.8.jar
    6. xhtmlrenderer-core-renderer-minimal.jar
    7. xml-apis-xerces_2_7_1.jar

    ReplyDelete
  31. I have tried this code and I am getting the following error:

    xception in thread "main" java.lang.NoClassDefFoundError: com/lowagie/text/pdf/PdfTemplate
    at org.xhtmlrenderer.pdf.ITextRenderer.(ITextRenderer.java:108)
    at org.xhtmlrenderer.pdf.ITextRenderer.(ITextRenderer.java:102)
    at models.CreatePdf.main(CreatePdf.java:28)
    Caused by: java.lang.ClassNotFoundException: com.lowagie.text.pdf.PdfTemplate
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 3 more
    Java Result: 1


    Any assistance would be appreciated.

    ReplyDelete
  32. Exception in thread "main" java.lang.NoSuchMethodError: com.lowagie.text.pdf.BaseFont.getCharBBox(I)[I

    is due to improper iText jar version:

    use iText-2.0.8.jar

    ReplyDelete
    Replies
    1. Hi Amarendra I have used iText-2.0.8.jar but still getting same issue.Please guide..vdubey.p@gail.com

      Delete
  33. Hello I am vivek yadav
    I am working on grails and using rendering plugin for generate pdf. behind the sceen it also use itext to create pdf. I want to add my own font how is it possible.
    You can email me if you have any solution regarding this.
    my email id is :
    vivek@jellyfishtechnologies.com

    ReplyDelete
    Replies
    1. Hi Vivek ,

      Can you please do let me know if you got any solution?

      vdubey.p@gmail.com

      Thanks,
      Ved

      Delete
  34. The type com.lowagie.text.DocumentException cannot be resolved. It is indirectly referenced from required .class files

    ReplyDelete
  35. hi..
    i'm tried this example in android but it will display error for "configure the build path"...so plz help me..

    The type com.lowagie.text.DocumentException cannot be resolved. It is indirectly referenced from required .class files

    ReplyDelete
  36. I have a table on my page and sometimes, this table has just been cut in half by page transition. would like to avoid this?

    ReplyDelete
  37. Hi! Thank you for a good article! I run your example, but I get an error ERROR: 'Stream closed'
    Exception in thread "main" org.xhtmlrenderer.util.XRRuntimeException: Can't load the XML resource (using TRaX transformer). java.io.IOException: Stream closed
    at org.xhtmlrenderer.resource.XMLResource$XMLResourceBuilder.createXMLResource(XMLResource.java:191)
    at org.xhtmlrenderer.resource.XMLResource.load(XMLResource.java:71)
    at org.xhtmlrenderer.swing.NaiveUserAgent.getXMLResource(NaiveUserAgent.java:212)
    at org.xhtmlrenderer.pdf.ITextRenderer.loadDocument(ITextRenderer.java:137)
    at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:141)
    at Converts.Html2Pdf.IText.HtmlToPdf.main(HtmlToPdf.java:14)
    Caused by: javax.xml.transform.TransformerException: java.io.IOException: Stream closed
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
    at org.xhtmlrenderer.resource.XMLResource$XMLResourceBuilder.createXMLResource(XMLResource.java:189)
    ... 5 more
    Caused by: java.io.IOException: Stream closed
    at java.io.BufferedInputStream.getInIfOpen(Unknown Source)
    at java.io.BufferedInputStream.fill(Unknown Source)
    at java.io.BufferedInputStream.read(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager$RewindableInputStream.read(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(Unknown Source)
    ... 8 more
    Tell me please how to fix it? Thank you!

    ReplyDelete
  38. it would be a useful example if you actually provided the libraries (as a download). Without those, it is just guess work because there is so many versions of those libraries out there that I cannot find the correct one.

    ReplyDelete
  39. Hi,

    I am using these all jars and everything is fine and pdf generated successfully
    but, when running same code on Windows10 then getting alignment issues (some contents comming in next page) which was fine when running in Windows7

    1) core-renderer.jar
    2) core-renderer-minimal.jar
    3) xml-apis-xerces-2.9.1.jar

    so, to execute on Windows10, I have to change new jar means latest jar for Win10 ?
    please help me out.

    ReplyDelete
  40. Exception in thread "main" java.lang.NoSuchMethodError: com.lowagie.text.pdf.BaseFont.getCharBBox(C)[I
    at org.xhtmlrenderer.pdf.ITextFontResolver$FontDescription.setMetricDefaults(ITextFontResolver.java:679)
    at org.xhtmlrenderer.pdf.ITextFontResolver$FontDescription.(ITextFontResolver.java:610)
    at org.xhtmlrenderer.pdf.ITextFontResolver.addCourier(ITextFontResolver.java:410)
    at org.xhtmlrenderer.pdf.ITextFontResolver.createInitialFontMap(ITextFontResolver.java:390)
    at org.xhtmlrenderer.pdf.ITextFontResolver.(ITextFontResolver.java:52)
    at org.xhtmlrenderer.pdf.ITextRenderer.(ITextRenderer.java:83)
    at org.xhtmlrenderer.pdf.ITextRenderer.(ITextRenderer.java:70)
    at com.jcg.examples.ItextHtmlToPDFExample.main(ItextHtmlToPDFExample.java:31) Please help

    ReplyDelete
  41. Hi,
    Getting below exception while executing the code in above mentioned format:
    Exception in thread "main" java.lang.NoSuchMethodError: com.lowagie.text.pdf.BaseFont.getCharBBox(C)[I
    at org.xhtmlrenderer.pdf.ITextFontResolver$FontDescription.setMetricDefaults(ITextFontResolver.java:679)
    at org.xhtmlrenderer.pdf.ITextFontResolver$FontDescription.(ITextFontResolver.java:610)
    at org.xhtmlrenderer.pdf.ITextFontResolver.addCourier(ITextFontResolver.java:410)
    at org.xhtmlrenderer.pdf.ITextFontResolver.createInitialFontMap(ITextFontResolver.java:390)
    at org.xhtmlrenderer.pdf.ITextFontResolver.(ITextFontResolver.java:52)
    at org.xhtmlrenderer.pdf.ITextRenderer.(ITextRenderer.java:83)
    at org.xhtmlrenderer.pdf.ITextRenderer.(ITextRenderer.java:70)
    at OSM.Pdf.main(Pdf.java:78)

    ReplyDelete
  42. Exception in thread "main" java.lang.NoSuchMethodError: com.lowagie.text.pdf.BaseFont.getCharBBox(C)[I
    at org.xhtmlrenderer.pdf.ITextFontResolver$FontDescription.setMetricDefaults(ITextFontResolver.java:679)
    at org.xhtmlrenderer.pdf.ITextFontResolver$FontDescription.(ITextFontResolver.java:610)
    at org.xhtmlrenderer.pdf.ITextFontResolver.addCourier(ITextFontResolver.java:410)
    at org.xhtmlrenderer.pdf.ITextFontResolver.createInitialFontMap(ITextFontResolver.java:390)
    at org.xhtmlrenderer.pdf.ITextFontResolver.(ITextFontResolver.java:52)
    at org.xhtmlrenderer.pdf.ITextRenderer.(ITextRenderer.java:83)
    at org.xhtmlrenderer.pdf.ITextRenderer.(ITextRenderer.java:70)
    at OSM.Pdf.main(Pdf.java:78)

    ReplyDelete