Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Send HTML or a publicly reachable URL to an authenticated rendering endpoint, then save the returned PDF bytes. The difficult part is not the HTTP request; it is reproducing a browser’s behavior reliably. JavaScript timing, CSS print rules, fonts, images, authentication, page size, and external-resource access determine whether the PDF is production-ready.

This guide explains the common API pattern, provides runnable cURL, Python, and Node.js examples, and gives a framework for choosing a provider for invoices, reports, certificates, archives, and other generated documents.

How an HTML-to-PDF API works

Most services expose an authenticated HTTP endpoint. Your request contains either:

  • url: a page the provider can reach, or
  • html: the complete markup to render.

The service loads the document in a browser-like engine, applies CSS and print settings, waits for the page to become ready, and returns a PDF—usually as binary data, although some APIs return JSON or Base64. Adobe documents static and dynamic HTML, URLs, ZIP packages, and optional rendered-HTML output. Cloudflare documents a /pdf browser action that accepts a URL or custom HTML. PDFCrowd describes one-call HTML or URL conversion.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • 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.

A minimal request with HTMLPDF.dev

HTMLPDF.dev documents POST https://api.htmlpdf.dev/api/pdf with a bearer token and a JSON body containing either url or html. The following examples write the response to a local file. Confirm your account’s current limits, output headers, and parameter names before deploying.

cURL: convert a URL

curl -X POST "https://api.htmlpdf.dev/api/pdf" 
  -H "Authorization: Bearer YOUR_API_TOKEN" 
  -H "Content-Type: application/json" 
  -d '{"url":"https://example.com/invoice/123"}' 
  -o invoice.pdf

Python: convert raw HTML

import requests

html = """
Invoice

Invoice 123

Total: $125.00

""" response = requests.post( "https://api.htmlpdf.dev/api/pdf", headers={ "Authorization": "Bearer YOUR_API_TOKEN", "Content-Type": "application/json", }, json={"html": html}, timeout=90, ) response.raise_for_status() with open("invoice.pdf", "wb") as file: file.write(response.content)

Node.js: convert a URL

const response = await fetch("https://api.htmlpdf.dev/api/pdf", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({ url: "https://example.com/invoice/123" })
});

if (!response.ok) {
  throw new Error(`PDF request failed: ${response.status} ${await response.text()}`);
}
const pdf = Buffer.from(await response.arrayBuffer());
require("node:fs").writeFileSync("invoice.pdf", pdf);

Keep tokens in environment variables or a secret manager, never in browser-side JavaScript or source control. Check the response Content-Type before treating it as a PDF; an authentication or validation error may be JSON or HTML.

Adobe’s documented HTML-to-PDF operation

Adobe PDF Services documents POST https://pdf-services.adobe.io/operation/htmltopdf authenticated with an API key and bearer token. Adobe’s workflow covers static and dynamic HTML, URL input, ZIP assets, page-layout controls, headers and footers, wait-time parameters, and optional rendered-HTML output. The exact token acquisition and request schema depend on your Adobe project, so use Adobe’s current API reference when implementing it rather than copying credentials into application code.

URL input versus raw HTML

Use a URL when

  • Your application already renders a canonical, authenticated page.
  • Assets are publicly reachable or the provider supports the required headers and cookies.
  • You want the PDF to reflect the same route users see.

Use raw HTML when

  • You generate invoices or reports server-side from trusted data.
  • The page must not be publicly exposed.
  • You need deterministic markup and a controlled asset bundle.

A URL is not automatically accessible just because it works in your browser. Private networks, login sessions, robots rules, signed URLs, firewall policies, and IP allowlists can prevent a provider from loading it. For sensitive documents, prefer raw HTML or a provider with explicit data-isolation and private-network controls.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 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.

Rendering fidelity: what changes the PDF

JavaScript and readiness

Browser-based conversion can execute JavaScript, but the converter must know when the page is ready. A page that fetches data after load may produce an empty table if the service captures too early. Prefer a deterministic “render complete” condition, such as a selector appearing, a known delay, or network-idle waiting. PDF.co says its HTML endpoint processes JavaScript triggered during page load; html2pdf.app states that headless Chromium rendering, CSS media mode, fonts, resource availability, and JavaScript timing affect output.

CSS print behavior

Define print-specific rules with @media print. Set page breaks deliberately using break-before, break-after, and break-inside; avoid splitting table rows where possible. Decide whether backgrounds and colors are required, and specify a paper format, orientation, and margins instead of relying on browser defaults.

Fonts and assets

Missing fonts change line wrapping and can add pages. Ensure every font, image, stylesheet, and script is reachable from the rendering environment. For repeatable output, package assets with the HTML or host them at stable HTTPS URLs. A successful HTTP response does not prove that every image loaded; inspect the generated PDF visually and, where possible, log browser console and network failures.

Options to compare before choosing a provider

Area Questions to answer
Input Does it accept raw HTML, URL, ZIP/package, or templates? Can it access authenticated content?
Fidelity Which browser engine and version are used? Are JavaScript, modern CSS, web fonts, SVG, and images supported?
Layout Can you set paper size, margins, orientation, headers, footers, background graphics, and page ranges?
Waiting Can capture wait for a selector, delay, network idle, or a custom readiness signal?
Output Is the result binary PDF, JSON, or Base64? Are content type and file size reported reliably?
Security How are URLs fetched, credentials handled, tenant data isolated, and temporary files deleted?
Operations What are timeout limits, retries, quotas, asynchronous jobs, webhooks, SDKs, and prices?

Do not select a universal “best” API from a feature list. Render representative documents—especially the longest invoice, a font-heavy report, and a JavaScript-generated table—then compare page count, line wrapping, images, links, and load time under your actual network conditions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • 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.

Production implementation checklist

  1. Make the document deterministic. Freeze locale, timezone, currency formatting, and data revision.
  2. Choose an input boundary. Use raw HTML for private generated documents; use a URL only when its access and dependencies are intentional.
  3. Set layout explicitly. Specify paper size, margins, orientation, print backgrounds, headers, and footers.
  4. Define readiness. Wait for the data table or other required selector rather than guessing a delay.
  5. Validate the response. Check status, content type, byte length, and a PDF parser or signature before storing it.
  6. Retry safely. Retry transient network and provider errors with exponential backoff and an idempotency strategy; do not duplicate paid document records.
  7. Observe failures. Record a request ID, template version, input type, duration, page count, and sanitized error details.
  8. Protect data. Redact personal information from logs and restrict who can request a URL conversion.

Common failures and fixes

The PDF is blank

The page may require JavaScript, authentication, or a readiness delay. Test the URL from an external network, provide raw HTML or supported credentials, and wait for a selector that proves content exists.

Images or fonts are missing

Check absolute HTTPS URLs, certificate validity, firewall rules, and CORS or hotlink protections. Bundle assets when the provider supports ZIP input, or host them where the rendering service can reach them.

The layout has extra pages

Different fonts, default margins, and print CSS commonly change wrapping. Set the font explicitly, define page margins and size, and inspect @media print rules and page-break properties.

JavaScript data is incomplete

Capture occurred before asynchronous work finished. Use selector, network-idle, or delay controls; then cap the wait and fail clearly when the selector never appears.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • 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 API returns JSON instead of a PDF

Inspect the status code and Content-Type. A 401 or 403 indicates credentials or permissions; a 400 usually indicates an invalid body or unsupported option. Save the error body for diagnosis, but do not expose tokens.

Requests time out

Reduce third-party resources, remove unnecessary scripts, optimize images, and split very large jobs. For slow or high-volume work, use an asynchronous job and webhook model when offered, with a polling timeout and dead-letter handling.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability, and cost considerations

Rendering time rises with page count, JavaScript execution, font downloads, image size, and third-party requests. Cache immutable assets, avoid analytics and advertisements in document routes, and keep templates close to the data source. Measure p50 and p95 latency, timeout rate, retry rate, and PDF validation failures—not just HTTP success.

Commercial terms vary by provider and can change. Compare per-document pricing, included pages, concurrency, overage behavior, asynchronous-job fees, and whether failed attempts are billed. Confirm retention and geographic processing requirements for regulated data before committing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 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.

Or skip the browser setup

If your goal is a clean visual capture of a webpage rather than a carefully paginated transactional PDF, ScreenshotNeo provides a single-request screenshot API and an MCP server for AI agents. Its cleanup step accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status.

Example request (the target URL can be changed):

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo documentation for PDF capture, full-page and element capture, device and retina settings, custom CSS or JavaScript, waiting rules, headers and cookies, blocking, caching, signed links, asynchronous webhooks, bulk capture, and usage details. The MCP tools take_screenshot, get_page_info, and capture_pdf let Claude, Cursor, or another MCP client operate the workflow. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for the free plan.

FAQ

Can an API convert a page that requires a login?

Only if the provider supports a secure way to supply the required session, headers, cookies, or authorization. Otherwise generate trusted HTML server-side or expose a short-lived, restricted URL.

Should I return a PDF synchronously from my web request?

Use synchronous conversion for small, fast documents. Queue larger or unpredictable renders as asynchronous jobs so user requests do not remain open until a browser timeout.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How do I test fidelity?

Use representative documents and compare text wrapping, fonts, images, page breaks, links, and total pages at the exact options and network conditions used in production.

Frequently Asked Questions

Can an API convert a page that requires a login?

Only if the provider supports a secure way to supply the required session, headers, cookies, or authorization. Otherwise generate trusted HTML server-side or expose a short-lived, restricted URL.

Should I return a PDF synchronously from my web request?

Use synchronous conversion for small, fast documents. Queue larger or unpredictable renders as asynchronous jobs so user requests do not remain open until a browser timeout.

How do I test fidelity?

Use representative documents and compare text wrapping, fonts, images, page breaks, links, and total pages at the exact options and network conditions used in production.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.