Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Use a normal HTML stylesheet link, then give your Java PDF renderer a base URI and permission to fetch the resource. For an absolute URL such as https://static.example.com/css/print.css, the renderer can request that URL directly. Relative links such as ../css/layout.css work only when the conversion has a correct document base URL. PDFreactor 12.7.1 loads linked resources automatically; iText uses a base URI (its documentation calls this BASEURI), and OpenHTMLtoPDF accepts a base URI when building the document. None of these libraries is a complete browser, so verify the CSS features your selected version supports.
The HTML that makes external CSS available
Put the stylesheet in the document head with a standard link element:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://static.example.com/css/print.css">
</head>
<body>
<h1>Report</h1>
</body>
</html>
An absolute HTTPS URL identifies the resource without any further path calculation. A relative URL is resolved against the document URL or an explicitly configured base URI. Do not confuse loading an HTML page from a URL with loading a CSS URL referenced by that page: they are separate resource-resolution steps.
Choose the right base URI
When the input is itself a URL
PDFreactor uses the document URL as the base when you submit a URL. Thus https://example.com/reports/june.html can resolve ../css/report.css relative to that location. Its web-service manual documents automatic loading of linked external resources.
#1 Best Overall
- INNOVATIVE CARTRIDGE-FREE PRINTING — No more dealing with lots of tiny ink cartridges; With this wireless document and photo printer each ink bottle set is equivalent to about 90 individual cartridges²
- LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; When you choose this combination printer, scanner and copier you can print up to 4,500 pages black/7,500 color³
- COLOR PRINTING — Up to 2 years of ink in the box4 (and with every replacement ink set) for fewer out-of-ink frustrations
- ZERO CARTRIDGE WASTE — By using an Epson EcoTank printer you can help reduce the amount of cartridge waste ending up in landfills
- HOME PRINTER DESIGNED FOR RELIABILITY — The Epson EcoTank ET-2800 All-in-One Supertank Color Printer creates vivid, detailed prints and documents thanks to Micro Piezo Heat-Free Technology; Fire off 10 ISO pages per minute1 to easily finish large jobs
When you supply HTML text or a local file
Text such as <link href="css/report.css"> has no useful origin by itself. Set a base such as https://example.com/reports/ (PDFreactor documents config.setBaseUrl(...)) or pass the equivalent base-URI setting in your renderer. iText describes the base URI as the parent location used to find CSS, images and other HTML resources. A trailing slash matters: it tells the resolver that the value is a directory.
Absolute URLs versus relative URLs
| Reference | What it needs | Typical failure |
|---|---|---|
https://cdn.example/css/print.css |
Network access from the Java process | TLS, authentication, firewall or timeout error |
/css/print.css |
An origin (scheme and host) in the base URI | Resolved to the wrong host or rejected as incomplete |
../css/print.css |
A correct directory base URI | File not found because the base points at the wrong folder |
OpenHTMLtoPDF: complete Java example
OpenHTMLtoPDF describes support for well-formed XML/XHTML, some HTML5 and CSS 2.1-plus standards. The following example supplies both HTML and its base URI, then writes a PDF:
import com.openhtmltopdf.pdfboxout.PdfRendererBuilder;
import java.io.FileOutputStream;
public class ExternalCssPdf {
public static void main(String[] args) throws Exception {
String html = """
<!doctype html>
<html><head>
<meta charset='UTF-8'>
<link rel='stylesheet' href='../css/print.css'>
</head><body>
<h1>Monthly report</h1>
<p>Rendered with an external stylesheet.</p>
</body></html>
""";
try (FileOutputStream pdf = new FileOutputStream("report.pdf")) {
new PdfRendererBuilder()
.withHtmlContent(html, "https://static.example.com/reports/")
.toStream(pdf)
.run();
}
}
}
Here ../css/print.css resolves to https://static.example.com/css/print.css. Replace the base with the directory that actually contains your HTML resources. The exact dependency coordinates and supported CSS vary by release; use the project documentation for the version in your build.
iText pdfHTML: set the base URI explicitly
iText’s pdfHTML maps parsed HTML and CSS to iText objects and styles. It does not evaluate JavaScript, so styles that depend on script-generated markup will not appear. A typical conversion with HTML text is:
Rank #2
- CARTRIDGE-FREE PRINTING — Print lab-quality photos, graphics and creative projects; Get vibrant colors and sharp text with Epson's high-accuracy printhead and Claria ET Premium 6-color inks
- INK BOTTLES — Save on photos1 and creative projects with affordable in-house printing; All-in-one printer allows you to print 4" x 6" photos for about 4 cents each vs. 40 cents with traditional ink cartridges1
- LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; Printer, scanner and copier lets you print up to 6,200 color pages³
- PRINT FOR LONGER — Up to 2 years of ink in the box² (and with every replacement ink set) for fewer out-of-ink frustrations with this wireless printer
- ZERO CARTRIDGE WASTE — Epson EcoTank printer helps reduce the amount of cartridge waste ending up in landfills; Cartridge-free printer uses high-yield ink bottles; Each replacement ink bottle set is equivalent to about 100 individual ink cartridges⁴
import com.itextpdf.html2pdf.HtmlConverter;
import com.itextpdf.html2pdf.ConverterProperties;
import java.io.FileOutputStream;
public class ITextExternalCss {
public static void main(String[] args) throws Exception {
String html = "<html><head>"
+ "<link rel='stylesheet' href='css/print.css'>"
+ "</head><body><h1>Report</h1></body></html>";
ConverterProperties properties = new ConverterProperties();
properties.setBaseUri("https://static.example.com/reports/");
try (FileOutputStream out = new FileOutputStream("report.pdf")) {
HtmlConverter.convertToPdf(html, out, properties);
}
}
}
The base URI is the parent location for css/print.css. If your CSS is protected, configure the renderer’s supported HTTP client, headers or resource resolver rather than assuming a browser session exists. Check the iText version’s API because method names and module packaging can change.
PDFreactor: URL input, HTML input and resource policy
Converting a page URL
When PDFreactor receives a page URL, that URL supplies the base automatically, and linked stylesheets are loaded as external resources. This is the simplest case for relative links.
Converting HTML with an explicit base
For HTML supplied as text or through another input method, configure the base URL. PDFreactor’s documented library API uses:
Recommended Free Tools
config.setBaseUrl("https://static.example.com/reports/");
Use the corresponding PDFreactor conversion call for your 12.7.1 integration; do not copy an API signature from iText or OpenHTMLtoPDF. Keep the base narrow and intentional when HTML is influenced by users.
Rank #3
- SET IT UP ONCE AND PRINT WITH CONFIDENCE. No complicated maintenance. Just easy, reliable printing you can count on.
- INK FOR YEARS. NOT MONTHS. Up to 2 years of ink included. Get thousands of pages of cartridge-free printing. More pages, less hassle
- KEEPS PRINTING WELL AFTER COMPETITORS HAVE QUIT. No complex maintenance. Sharper text, richer colors.[2] Only with HP Smart Tank
- PREMIUM SUPPORT - Strong technical expertise to solve issues faster
- THE LAST PRINTER YOU'LL EVER NEED. Enjoy years of refillable, cartridge-free printing.
HTTPS, timeouts and access controls
PDFreactor 12.7.1 verifies HTTPS certificates and documents configurable connection and read timeouts. Its defaults restrict protocols, disable filesystem access and control which network addresses can be contacted. Permit only the hosts and schemes required for the conversion. Broad filesystem or private-network access can expose internal resources when an untrusted document controls a URL.
Make sure the renderer can actually fetch the stylesheet
- Check the generated HTML. Log the final HTML and confirm one enabled
linkelement points to the intended URL. - Test from the conversion host. A URL that works in your laptop browser may be blocked by a container firewall, proxy, DNS policy or certificate store.
- Resolve the URL yourself. For relative links, print the base URI and the resolved absolute URL; a missing directory slash is a common error.
- Check authentication. Cookies, bearer headers and client certificates are not automatically inherited from a browser.
- Inspect timeouts and redirects. A slow CDN or redirect to a blocked host can make the stylesheet appear to be ignored.
- Check CSS support last. Once the bytes are fetched, confirm that the renderer implements the selectors, layout features, fonts and media rules you use.
Why browser output and PDF output differ
These libraries are document renderers, not interchangeable browser engines. iText’s FAQ explicitly states that pdfHTML does not evaluate JavaScript. OpenHTMLtoPDF documents a bounded XHTML/HTML5 and CSS subset. PDFreactor has its own supported-feature and security configuration. Browser-only constructs, script-created elements, unsupported selectors, web components and interactive effects may therefore disappear or render differently. Build a small fixture containing your actual fonts, tables, page breaks, pseudo-elements and media queries, and run it against the exact library version you deploy.
Security and reliability checklist
- Allow only
https(and local resources you deliberately control). - Use an allowlist for stylesheet hosts when URLs come from users or external feeds.
- Keep filesystem access disabled unless a documented requirement demands it.
- Block private and link-local network ranges in server-side conversion services.
- Set finite connect and read timeouts and enforce a total job deadline.
- Cache immutable CSS at your application or CDN layer, but invalidate it when deploying a new stylesheet.
- Record the HTML URL, resolved CSS URLs, response status, content type and renderer version for diagnostics; avoid logging secrets in query strings.
Common failures and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Everything is unstyled | The link is missing, blocked or malformed |
Inspect final HTML and fetch the exact URL from the Java host. |
| Absolute CSS works; relative CSS fails | No base URI or an incorrect one | Set the renderer’s base URL to the resource directory. |
| Works locally, fails in production | DNS, proxy, firewall or certificate differences | Test connectivity inside the production container and install the required CA chain. |
| Intermittent missing styles | Read timeout or overloaded origin | Increase the documented read timeout within a job deadline, and make the CSS host reliable or cache it. |
| 403 or login HTML returned as CSS | Authentication or authorization is required | Provide supported request credentials or publish a conversion-safe stylesheet endpoint. |
| CSS fetched but a feature is absent | Renderer support boundary | Check the version’s CSS support and replace or simplify the unsupported rule. |
| Fonts or images fail while CSS loads | Those URLs have their own relative paths or access rules | Resolve each resource against the same base and authorize every required host. |
When a screenshot or PDF API is a better fit
If your requirement is a hosted capture rather than embedding a Java renderer, ScreenshotNeo is the first service to try: it produces clean shots, bills only clean captures, and its paid entry plan is $5 for 3,000 shots. It is a website screenshot API and MCP server, not a replacement for a Java PDF library when you need server-side document composition.
Or skip the browser setup
For a one-call capture, use the API documented at https://screenshotneo.com/docs/:
Rank #4
- Wireless Bluetooth Printer: Portable thermal printer compatible with iPhone, Android phones, iPad and tablet computers via Bluetooth. For smartphones, please download the "Nada Print" App. You can also connect to laptops and computers for printing using a USB-C cable. (Note: Laptops and computers can only be connected via USB and require the installation of a driver first. Bluetooth connection is not supported.)
- No-ink printing: Only supports US Letter and A4 size thermal paper.(Doesn't support regular paper) The no-ink portable thermal printer uses direct thermal technology, requiring no ink, toner or ribbons, making it environmentally friendly, cost-effective and time-saving. The thermal printer package comes with a roll of US Letter thermal printing paper. Note: When installing the paper, remember to switch the paper size switch on APP
- Clear Print: NDYIN N80 portable thermal printer adopts high-definition printing technology, with a 203DPI resolution to provide you with clear printing results. This mobile printer is compatible with roll paper, folded paper and tattoo transfer paper, supporting printing from your mobile phone PDF, Word, pictures and web pages anytime and anywhere. It is recommended to use our NDYIN thermal paper to achieve good printing quality
- Portable wireless printer for travel: The thermal printer is equipped with a built-in 1500mAh rechargeable battery, which can print 160 sheets of 8.5" x 11" thermal paper after being fully charged. It weighs only 1.5 pounds and is compact in size. This ink-free portable printer can be easily carried in a backpack or briefcase! It is perfect for business travel, cars, small offices, construction sites, schools and homes. You can print documents, contracts, invoices and boarding passes anytime and anywhere
- The N80 thermal printer has a wide range of uses. The package includes the N80 printer, a roll of US Letter paper(7m/roll), a user manual, a guide card, a type-C soft cable and a type C adapter. Note: The charging adapter is not included. Special thermal paper is required for use; ordinary paper cannot be used. This ink-free portable thermal printer is suitable for various scenarios such as home, school, travel, office, and outdoor, meeting the printing needs of different groups of people. This tattoo template printer is also compatible with tattoo transfer paper, making it an ideal choice for tattoo art
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
ScreenshotNeo accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be disabled. Bot checks, blank pages, failed loads and cache hits are not billed, and response headers identify the page verdict and billing result. Its MCP server provides take_screenshot, get_page_info and capture_pdf for Claude, Cursor and other MCP clients. The Free plan includes 1,000 screenshots each month without a card; paid plans start at $5 for 3,000. Create a free ScreenshotNeo account.
Validate before shipping
- Convert a fixture with an absolute stylesheet URL.
- Convert the same fixture with a relative URL and an explicit base URI.
- Run from the production network, not only a developer workstation.
- Test expired certificates, 403 responses, slow responses and redirects.
- Compare representative pages for page breaks, fonts, images, tables and unsupported CSS.
- Pin the renderer version and retain a regression PDF for every upgrade.
Frequently Asked Questions
Does an HTML link tag work with every Java PDF library?
It is the standard HTML mechanism, but each renderer has its own resource loader, security policy and CSS support. Confirm the selected version’s documentation.
Should I inline the CSS instead?
Inlining can remove network and base-URI problems, but it changes caching and build workflows. External CSS is appropriate when the renderer can reach the URL reliably.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsWill JavaScript load the stylesheet before conversion?
Do not assume it. iText pdfHTML does not evaluate JavaScript, and other renderers have bounded browser compatibility.
Quick Recap
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.

