Nutrient Java SDK
Need pricing or implementation help? Talk to Sales.
HTML-TO-PDF CONVERSION
package io.nutrient.Sample;
import io.nutrient.sdk.Document;import io.nutrient.sdk.exceptions.NutrientException;
public class HtmlToPDF { public static void main(String[] args) throws NutrientException { try (Document document = Document.open("input.html")) { document.exportAsPdf("output.pdf"); } }}USE CASES
Render an HTML invoice or receipt template — styled with your own CSS — into a fixed PDF for emailing, billing, and record keeping.
Turn dashboards, statements, and generated reports built as HTML into print-ready PDFs with consistent pagination and layout.
Capture rendered webpages as PDFs for offline access, audit trails, and long-term archiving where a stable format is required.
Nutrient renders HTML through Chrome, so fonts, images, and CSS styling come through exactly as they appear in the browser.
Convert Markdown to PDF in Java. The SDK parses Markdown and renders formatted PDF output.
exportAsPdf()Convert DOCX to PDF in Java. The SDK renders Word documents to PDF with no Microsoft Office required.
exportAsPdf()Convert XLSX to PDF in Java. The SDK renders spreadsheets to PDF for sharing and archiving.
exportAsPdf()ADVANCED CAPABILITIES
The SDK handles more than one-off conversions. Build HTML-to-PDF conversion into automated workflows and deploy anywhere the JVM runs.
HTML is rendered through Chrome, so complex CSS, web fonts, and images appear in the PDF exactly as they do in the browser.
Convert many HTML files in a loop or across threads. Each conversion follows the same pattern: open and export.
No GUI dependencies — run HTML-to-PDF conversion in background jobs, services, or API handlers on any server.
Run conversions in containers by including Chrome in the image and running as a non-root user, following the Docker deployment guide.
Install Nutrient Java SDK. Then open your HTML file with Document.open("input.html") and call document.exportAsPdf("output.pdf"). The SDK renders the HTML through Chrome and writes a PDF that preserves the page’s layout, fonts, images, and CSS. See the HTML-to-PDF guide for a complete working example.
Yes. Nutrient renders HTML through Chrome, so CSS, web fonts, images, and page layout come through in the PDF exactly as they appear in the browser. You don’t need to implement any rendering or pagination logic yourself.
No template engine or browser-automation framework is required in your code — the conversion is a single exportAsPdf() call inside a try-with-resources block. The SDK uses Chrome internally for rendering; on first run, it provisions the rendering engine for you.
Yes. The SDK is server-ready and runs on Linux. Because HTML rendering relies on Chrome, a containerized deployment needs Chrome included in the image and the container run as a non-root user. See the guide on Chrome-based conversions in Docker for the packaged setup.
Loop over your HTML files, or convert across threads, and run the same two-step conversion for each one: Document.open(...), then exportAsPdf(...). Because there are no GUI dependencies, the same code runs in background services and CI/CD pipelines.
Yes. The open-then-export pattern is the same across formats. Use exportAsPdf() after opening Markdown, Word (DOCX), Excel (XLSX), or PowerPoint (PPTX). See the Java conversion guides for each format.
Conversion methods can throw NutrientException, so declare or catch it. Use a try-with-resources block (try (Document document = Document.open(...))) so the document is closed automatically, even when an error occurs.
FREE TRIAL
Start converting HTML to PDF in Java in minutes — no payment information required.
Also available for
More Java SDK capabilities