The journal · 3 December 2026 · 6 min read
Flying Saucer and OpenHTMLToPDF or a Rendering API and What a Year Costs
Flying Saucer and OpenHTMLToPDF are free but need strict XHTML and print only CSS 2.1, so a web view needs a second template. At 8,000 documents a month an API costs about $588 in year one against about $3,930.
Live demo
Runs in your browser. Nothing is uploaded. One PDF free to try, then a plan.
Your HTML
Live preview
Your PDF is downloading. That was the free one. The Starter plan converts as many as you need, for $49 a month or $288 a year, half price.
See the planSitePDF is an HTML to PDF API, and this article is for a Java team that prints invoices or reports with Flying Saucer or OpenHTMLToPDF and is deciding whether to keep doing so. The short answer is that both libraries are free and work well for simple, strictly written pages, but they run their own CSS 2.1 engine, so a layout built for the browser needs a second template. At 8,000 documents a month, an API costs about $588 in year one against about $3,930 for keeping the library and its template.
The short answer
Flying Saucer (the xhtmlrenderer project) lays out XHTML and CSS 2.1 and hands the result to a PDF writer. OpenHTMLToPDF is a fork that moved to Apache PDFBox and added fonts, SVG and a few modern touches. Neither is a browser. Anything the browser does that CSS 2.1 does not describe, such as flexbox, grid or a custom property, is ignored or drawn wrong.
That is fine for a letter or a plain table. It is a real cost when your invoice already exists as a web page and someone has to rebuild it as strict markup for the PDF.
What goes wrong with Flying Saucer in production?
| Symptom | Cause | Usual fix |
|---|---|---|
| A parse exception on a page that works in the browser | The input must be well formed XHTML, so an unclosed tag or a bare ampersand fails | Run the HTML through a cleaner such as jsoup before rendering |
| Flexbox rows stack or overlap | The engine knows floats and tables, not flexbox or grid | Rewrite the layout with tables |
| Wrong or missing font | Fonts must be registered with the renderer, web font links are not followed | Register each TTF in code |
| Totals or charts missing | No JavaScript runs | Compute values on the server, drop the chart |
| Different output after a library upgrade | Layout rules are the library's own | Pin the version and re-test every template |
The project pages are the best source for current limits: Flying Saucer and OpenHTMLToPDF. Both are LGPL licensed, which most teams can use in a closed product, though a lawyer should read it for your case.
What does a year cost, library against API?
These are planning assumptions, not measurements. Take a billing service in Java that sends 8,000 invoices and statements a month, for example the monthly spend reports an ad platform such as Adbot would send its customers. The rate is $75 an hour and one render counts per document.
| Cost line | Keep the library | SitePDF Starter API |
|---|---|---|
| Second print template, strict XHTML | 16 hours, $1,200 | $0, the web view is reused |
| Font registration and first set up | 6 hours, $450 | 4 hours to swap the call, $300 |
| Upkeep when the web view changes | 2 hours a month, $1,800 | $0 |
| Memory for the PDF job on your JVM | $40 a month, $480 | $0 |
| Service fee | $0 | $288 billed yearly |
| Year one | $3,930 | $588 |
If your invoice is already a plain table and nobody edits it, the left column drops toward $450 and the library wins. The right column is fixed by the pricing page: Starter API is $49 a month for 10,000 renders, Growth is $99 a month for 50,000 and Scale is $299 a month for 250,000.
How do you switch from Flying Saucer to an API?
Keep your Thymeleaf, FreeMarker or JSP output and remove the XHTML cleaning step. Post the HTML and download the PDF.
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.sitepdf.com/v1/render"))
.header("Authorization", "Bearer " + System.getenv("SITEPDF_KEY"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(
"{\"html\": " + json(html) + ", \"format\": \"Letter\", \"archive\": true}"))
.build();
HttpResponse<String> res = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
Page size is format. Page numbers come from header_html and footer_html, covered in page numbers and footers. With archive set, the render is stored with a SHA-256 hash, which helps when a customer disputes an invoice, see invoice PDF archive.
Where do the other Java options fit?
PDFBox alone cannot read HTML, as our note on Apache PDFBox and HTML explains. iText converts HTML with an add on and a commercial license for closed products. For the full set of routes, including Playwright for Java, see the Java PDF library comparison, and for JVM licensing in more detail the Kotlin and JVM cost article.
Who this is for and who it is not for
It is for Java teams whose invoices or reports are already web pages and who maintain a second strict template just for PDF. It is not for teams that cannot send document content to an outside service, or ones printing a few simple letters a month, where a library in the JAR costs nothing. General sums are in library versus API.
What to do this week
Take the most complex document you print and send its web view to SitePDF next to your current output. If both match the screen, keep the library. If you find a table rewrite or a missing chart, the API removes that template. Plans are on the pricing page.
Frequently asked questions
Is Flying Saucer still maintained?
It is maintained at a slow pace and stays a CSS 2.1 engine. New CSS such as flexbox and grid is not on its path, so a web view built with modern CSS will not print the same through it.
What is the difference between Flying Saucer and OpenHTMLToPDF?
OpenHTMLToPDF started as a fork of Flying Saucer, switched its PDF output to Apache PDFBox and added font, SVG and accessibility work. Both need well formed XHTML and neither runs JavaScript.
Can Flying Saucer render flexbox or CSS grid?
No. It implements CSS 2.1, so flexbox and grid layouts need a table or float rewrite. A Chromium based renderer prints them as the browser does.
How much does an HTML to PDF API cost for Java?
SitePDF Starter API is $49 a month for 10,000 renders, or $288 billed yearly. Growth is $99 a month for 50,000 renders and Scale is $299 a month for 250,000. Count one render per document.
Written by the team behind SitePDF, an HTML to PDF API that archives every page it renders. The in-browser converter is free to try, and API plans start at $49 a month, half price billed yearly.