An HTML to PDF library for the JVM. Based on Flying Saucer and Apache PDF-BOX 2. With SVG image support. Now also with accessible PDF support (WCAG, Section 508, PDF/UA)!
<html>
<head>
<style>
@page {
margin: 50px 20px;
@bottom-left {
content: element(whatever);
}
}
</style>
</head>
<body>
<div style="position: running(whatever);">
This is some <strong>richly</strong> styled html!<br/>
<span style="color: red;">This is another line.</span>
</div>
<h1>Rest of content</h1>
<p>Etc, etc, etc...</p>
</body>
</html>
with the Java code:
PdfRendererBuilder builder = new PdfRendererBuilder();
builder.usePdfUaAccessbility(true);
builder.toStream(out);
builder.run();
and I get the exception:
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:668)
at java.util.ArrayList.get(ArrayList.java:444)
at com.openhtmltopdf.pdfboxout.PdfBoxFastOutputDevice.drawString(PdfBoxFastOutputDevice.java:390)
at com.openhtmltopdf.pdfboxout.PdfBoxTextRenderer.drawString(PdfBoxTextRenderer.java:60)
at com.openhtmltopdf.render.AbstractOutputDevice.drawText(AbstractOutputDevice.java:105)
at com.openhtmltopdf.render.InlineText.paint(InlineText.java:171)
at com.openhtmltopdf.render.InlineLayoutBox.paintInline(InlineLayoutBox.java:284)
at com.openhtmltopdf.render.simplepainter.SimplePainter.paintInlineContent(SimplePainter.java:170)
at com.openhtmltopdf.render.simplepainter.SimplePainter.paintLayer(SimplePainter.java:72)
at com.openhtmltopdf.render.PageBox.paintMarginAreas(PageBox.java:487)
at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.paintPageFast(PdfBoxRenderer.java:920)
at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.writePDFFast(PdfBoxRenderer.java:628)
at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.createPdfFast(PdfBoxRenderer.java:564)
at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.createPDF(PdfBoxRenderer.java:490)
at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.createPDF(PdfBoxRenderer.java:427)
at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.createPDF(PdfBoxRenderer.java:409)
at com.openhtmltopdf.pdfboxout.PdfRendererBuilder.run(PdfRendererBuilder.java:46)
"Workaround": Removing builder.usePdfUaAccessbility(true); creates the PDF.
Using Java 8, Windows, openhtmltopdf v1.0.10.
I tried recreating the example from https://github.com/danfickle/openhtmltopdf/issues/352
HTML:
with the Java code:
and I get the exception:
"Workaround": Removing
builder.usePdfUaAccessbility(true);
creates the PDF.