iText 7 HTML to PDF conversion [duplicate]

2019-02-27 21:47发布

问题:

This question already has an answer here:

  • iText 7 java.lang.NoSuchMethodError 1 answer

I am using iText 7 for PDF generation.I need to append Rich Text which having HTML document. In itext 5, i was using Chunk class for extracting data. But in itext 7 I don't see any API.

And I tried with the code

HtmlConverter.convertToPdf(is, os, properties);

But it is giving below error.

Exception in thread "main" java.lang.NoSuchMethodError: com.itextpdf.layout.font.FontSet.getFonts()Ljava/util/Set;
at com.itextpdf.html2pdf.attach.impl.DefaultHtmlProcessor.processDocument(DefaultHtmlProcessor.java:107)
at com.itextpdf.html2pdf.attach.Attacher.attach(Attacher.java:18)
at com.itextpdf.html2pdf.HtmlConverter.convertToDocument(HtmlConverter.java:108)
at com.itextpdf.html2pdf.HtmlConverter.convertToPdf(HtmlConverter.java:85)
at com.itextpdf.html2pdf.HtmlConverter.convertToPdf(HtmlConverter.java:81)
at com.itextpdf.html2pdf.HtmlConverter.convertToPdf(HtmlConverter.java:69)
at com.itextpdf.html2pdf.HtmlConverter.convertToPdf(HtmlConverter.java:65)

回答1:

After updating versions to 7.0.3 and 1.0.0, issue is resolved.