A Scala service turns an order into order-confirmation.pdf from a template and a handful of values. Then the order form gains a delivery note field, customers type whatever they like into it, and that text lands in the same template. The question for the renderer changes from how it lays out a page to what exactly reaches it.
Our released IronPDF for Java already runs in Scala services, and IronPDF for Scala is coming soon, with early-access sign-up. Before either of them, the same template goes through OpenHTMLtoPDF.
We work at Iron Software, and the end of this article covers our library, IronPDF.
How does OpenHTMLtoPDF render a template from Scala?
It renders through a builder that takes a source and a target and then runs once. OpenHTMLtoPDF is a pure-Java library that lays out a reasonable subset of well-formed XML or XHTML, and some HTML5, with CSS 2.1 and later standards. Output goes to PDF through Apache PDFBox, and the library can also produce images. It grew out of Flying Saucer, and Scala calls it like any other Java dependency.
import java.io.FileOutputStream import com.openhtmltopdf.pdfboxout.PdfRendererBuilder // The builder takes a well-formed XHTML file and an output stream. val out = new FileOutputStream("order-confirmation.pdf") val builder = new PdfRendererBuilder() builder.withUri("file:///srv/templates/order-confirmation.xhtml") builder.toStream(out) // One call lays out the document and writes the PDF. builder.run() out.close() That render stays inside what the project recommends, because the file is well formed and nobody outside the team wrote a character of it.
What changes when the template takes user text?
The renderer starts to receive input that a customer wrote. The delivery note reaches the page through one line.
// The customer's note goes straight into the template string. val note = order.deliveryNote val page = template.replace("{{deliveryNote}}", note) OpenHTMLtoPDF expects strict XML by default, so an HTML5 template with an unclosed <br> needs converting first. The documented route parses the page with Jsoup, converts it with the fromJsoup method of W3CDom and hands the result to builder.withW3cDocument(doc, url). Every HTML5 template therefore carries a conversion step that the team owns.
The project's position, repeated across its changelog, is that untrusted SVG and XML are strongly advised against. A note passed through as markup, tags and all, is user-supplied XML arriving at the renderer, which is exactly the input the project advises against. A note that is escaped first, so that a typed <b> prints as three visible characters, stays a data value in a fixed template.
Which dependency fixes has OpenHTMLtoPDF shipped?
Its changelog records CVE fixes in its dependencies and one fix in its own code marked as security. The dependency entries name Apache Batik, which draws SVG, PDFBox, which writes the file, and xmlgraphics-commons, which is also used in SVG rendering. Batik moved to 1.14 and PDFBox to 2.0.24 in version 1.0.9, and xmlgraphics-commons moved in 1.0.10. The fix in the library's own code stopped an almost endless loop on deeply nested content with page-break-inside: avoid, also in 1.0.10.
Version 1.0.10, the last release under the com.openhtmltopdf group on Maven Central, is dated September 13, 2021, and the last commit on the project's default branch is dated April 1, 2022. On those artifacts, any dependency version newer than the ones 1.0.10 pulls in is a line the team adds to its own build.
OpenHTMLtoPDF strengths on a JVM back end
Several of its features suit server-side JVM code. It runs on Java 8 or later with no native binary to ship, and it generates accessible PDFs under Section 508, PDF/UA and WCAG 2.0, as well as PDF/A. Its README also lists footnotes, font fallback, CSS3 transforms and built-in SVG and MathML plugins, and the project runs automatic visual regression tests across many end-to-end cases.
How does IronPDF for Java handle the same template in Scala?
It renders the HTML5 template as web content, with no XHTML conversion in front. IronPDF for Java is a released library that supports Java, Scala and Kotlin on Java 8 or later, and a Scala service calls it as it would any Java library.
import com.ironsoftware.ironpdf.PdfDocument object OrderConfirmation { def main(args: Array[String]): Unit = { // The HTML5 template renders as written, with its stylesheet and scripts. val confirmation = PdfDocument.renderHtmlFileAsPdf("order-confirmation.html") confirmation.saveAs("order-confirmation.pdf") } } Rendering an HTML file also loads the stylesheets, scripts and images that the file references by relative path. In the PDF from that listing, the layout follows the stylesheet, the total is the figure that the template's script computed, and the delivery note prints its <b> tags as text.
IronPDF for Java also handles the steps that usually follow a confirmation, including running headers and footers and digital signatures. According to its product page, the dedicated IronPDF for Scala edition will let Scala code produce and edit PDFs.
Which Scala template should switch to IronPDF first?
The template that takes user text should switch first, since it carries the conversion step and the input question together.
- Escape the note in the current renderer: until the move is done, print the delivery note as text so the template stays inside what OpenHTMLtoPDF asks for.
- Render the HTML5 version with IronPDF for Java: use the template as written, without the Jsoup conversion, and compare it with the current PDF page by page.
- Move the remaining templates: point each one at IronPDF for Java once its output matches, and remove the conversion step from the build.
- Register for the Scala edition: use the sign-up form on the IronPDF for Scala page on ironpdf.com to try that edition when it opens.
Everything said here about OpenHTMLtoPDF traces to its repository, README and changelog. In our run on November 26, 2026, the IronPDF for Java listing compiled with Scala 2.13.10 against com.ironsoftware:ironpdf 2026.11.3 and turned the HTML5 confirmation, stylesheet and script total included, into a one-page PDF. We would start with the template behind the delivery note, rendered in the existing sbt project with IronPDF for Java under a 30-day trial key.
Drafted with AI. On November 26, 2026, the IronPDF for Java listing was compiled with Scala 2.13.10 on Java 17 and run against com.ironsoftware:ironpdf 2026.11.3. The OpenHTMLtoPDF listing and the Jsoup route were compiled against openhtmltopdf-pdfbox 1.0.10, the other OpenHTMLtoPDF claims were checked against its repository, README and changelog, and the IronPDF for Scala claims against its product page.
OpenHTMLtoPDF, Flying Saucer, Apache PDFBox, Apache Batik, Jsoup, Scala and Java are trademarks of their respective owners, we have no affiliation with any of them, and the facts above come from the OpenHTMLtoPDF repository, README and changelog, the IronPDF for Java documentation, our run of the IronPDF for Java listing and the IronPDF for Scala page on ironpdf.com.