I used Flying Saucer library to convert html to pdf. It used to work fine then suddenly one day the conversion failed to render any image in the output pdf file. Below is the method I used to convert html to pdf:
public static void convertHtml2Pdf(String htmlPath, String pdfPath) throws FileNotFoundException, IOException, com.lowagie.text.DocumentException {
final ITextRenderer iTextRenderer = new ITextRenderer();
iTextRenderer.setDocument(htmlPath);
iTextRenderer.layout();
/** The generated pdf will be written to the file. */
final FileOutputStream fileOutputStream =
new FileOutputStream(new File(pdfPath));
/** Creating the pdf */
iTextRenderer.createPDF(fileOutputStream);
fileOutputStream.close();
}
My investigation has shown that the code is stuck at iTextRendered.layout() forever. Does anyone encounter this issue before and have any idea how to fix this? Thanks.