Free tools Windows power users keep installed
One-click scans. No signup required.
For OpenPDF 3.0.5, add the openpdf-html module, pass your HTML to ITextRenderer, call layout(), then write the PDF with createPDF(). The renderer is derived from Flying Saucer; it is not a full browser, so validate the output against your real templates, styles, fonts, and images.
1. Add the OpenPDF dependencies
The HTML renderer is published as com.github.librepdf:openpdf-html. The matching core artifact is com.github.librepdf:openpdf. The project README and Maven Central listing identify version 3.0.5; check the current published version before pinning these declarations because releases can change. OpenPDF project README · Maven Central: openpdf-html
Maven
<dependencies>
<dependency>
<groupId>com.github.librepdf</groupId>
<artifactId>openpdf-html</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>com.github.librepdf</groupId>
<artifactId>openpdf</artifactId>
<version>3.0.5</version>
</dependency>
</dependencies>
Keep the HTML module and core on compatible versions. If your project uses Gradle or another build system, declare the same two Maven coordinates there.
2. Convert an HTML string to a PDF
This example follows the API flow documented by OpenPDF’s module README. It uses a try-with-resources block so the output file is closed even if conversion throws an exception. The sample is illustrative; adapt and test it with your selected version and document requirements. OpenPDF HTML module README
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
import org.openpdf.pdf.ITextRenderer;
import java.io.FileOutputStream;
import java.nio.charset.StandardCharsets;
public class HtmlToPdf {
public static void main(String[] args) throws Exception {
String html = "<html><body>"
+ "<h1>Invoice</h1>"
+ "<p>Generated with OpenPDF.</p>"
+ "</body></html>";
try (FileOutputStream output = new FileOutputStream("output.pdf")) {
ITextRenderer renderer = new ITextRenderer();
renderer.setDocumentFromString(html);
renderer.layout();
renderer.createPDF(output);
}
}
}
The order matters: provide the document, lay it out, and only then create the PDF. createPDF() writes to the supplied stream; choose and manage that stream according to your application, whether the destination is a file, an HTTP response, or another output target.
3. Match package names to the OpenPDF version
OpenPDF 3.0 uses the org.openpdf.* namespace and removes the older com.lowagie.* namespace. The current HTML-module sample imports org.openpdf.pdf.ITextRenderer. If a copied example fails with a missing package or class, check that its imports match your dependency version rather than mixing a 3.0 artifact with older imports. OpenPDF release notes
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
4. Set realistic HTML and CSS expectations
openpdf-html is a Flying Saucer-derived renderer. The project describes improved CSS3 compatibility while noting that modern HTML5 support is in progress; that does not mean it reproduces a browser’s rendering completely. Before relying on generated PDFs, test representative documents for the styles and resources they actually use. OpenPDF HTML module README
- Check page dimensions, margins, page breaks, and long content.
- Verify that fonts and images load from the references used in your deployment environment.
- Test CSS features your templates depend on instead of assuming browser-equivalent support.
- Include malformed, unusually long, or resource-missing documents in application-level tests where relevant.
5. Protect untrusted HTML and resource access
The OpenPDF README puts responsibility on the application developer to ensure input is trusted, sanitized, and safe. It also says OpenPDF does not validate input or enforce sandboxing. Treat user-provided HTML and resource URLs as security-sensitive: validate content, constrain which resources may be fetched, and provide isolation and access restrictions at the application or infrastructure layer. Do not treat the renderer as a security boundary. OpenPDF security notice
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
6. Check the licenses of both artifacts
The project identifies the core OpenPDF library as dual-licensed under MPL 2.0 or LGPL 2.1, while openpdf-html and openpdf-renderer are identified as LGPL 2.1 only. Review the applicable license texts and your distribution context before shipping; the obligations depend on the artifacts and how you use and distribute them. OpenPDF licensing information
7. Troubleshoot common conversion problems
Compilation fails on ITextRenderer or imports
Confirm that openpdf-html is on the classpath and that imports use the namespace for your OpenPDF version. For 3.0, use the documented org.openpdf namespace rather than older com.lowagie examples.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
The PDF is blank or content is missing
Confirm that you set the HTML on the renderer and called layout() before createPDF(). Then inspect the actual HTML and resource references and verify that referenced images or fonts are available to the conversion process.
The result differs from a browser preview
Check whether the template relies on HTML5 or CSS behavior the renderer does not support as expected. Reduce the document to a small reproducible case, then test the needed markup, styles, fonts, and page breaks with your selected release.
Recommended Free Tools
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Conversion fails on user-supplied content
Do not assume OpenPDF sanitizes or isolates the input. Validate the HTML and restrict resource access in your own application, including any network or local-file access your deployment permits.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
If the goal is a rendered page PDF from a URL rather than an OpenPDF Java conversion pipeline, ScreenshotNeo offers a website screenshot API that can return a PDF. A single GET request is:
Quick Recap
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.pdf
See the ScreenshotNeo API documentation for request options. Cookie banners, popups, and chat widgets are removed before capture; bot checks, blank pages, and failed loads are never billed. An MCP server lets AI agents take screenshots, and the Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for free.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

