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

Use an HTML-to-PDF API that accepts your input type—raw HTML, a public URL, or an uploaded file/archive—then make every image reachable to the renderer. Submit authentication and rendering options such as page size, margins, print CSS, backgrounds, viewport, and wait behavior. Save the returned PDF bytes only after checking the status and content type, then inspect real output for missing images, clipping, and page-break problems.

API behavior is provider-specific. HTMLPDF documents mutually exclusive URL, file, and HTML inputs; Adobe PDF Services documents static or dynamic HTML, ZIP, and URL conversion; PDF.co documents page, print, background, margin, header, and footer controls. Treat those as documented product capabilities, not guarantees shared by every service.

Choose how your document enters the API

Start by deciding what the renderer should receive. The choice affects image access, authentication, and repeatability.

Raw HTML

Send HTML generated by your application when you control the template and want a self-contained request. Include a base URL when relative links are used, if the selected API supports one. Raw HTML is useful for invoices, reports, and transactional documents because the source can be versioned with the application.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

Public page URL

Send a URL when the provider can reach the page from its own network. The page must be available without your browser session, local DNS, or an unforwarded VPN. A URL that works in your browser can still fail remotely because of authentication, geographic restrictions, robots or bot checks, or a page that has not finished rendering.

Uploaded file or archive

Use a file or ZIP when the document depends on local assets, private images, fonts, or a directory of related files. Adobe documents HTML, ZIP, and URL inputs, while HTMLPDF documents URL, file, or HTML as separate choices. Follow the selected provider’s upload and asset-reference rules rather than assuming a ZIP layout will work everywhere.

Input Best fit Main risk
HTML string Templates generated by your application Relative or protected resources cannot be resolved
URL Already published pages Renderer cannot access the page or dynamic content is not ready
File/archive Private or reusable assets Provider-specific packaging and path rules

Make images available to the renderer

The conversion service must obtain the actual image bytes while it renders. For each <img src> and CSS image reference, verify the following:

  • Use an absolute, resolvable URL when the image is hosted externally, or provide a documented base URL for relative paths.
  • Ensure the renderer’s network can reach the host and that the response does not require browser cookies, a local filesystem, or an interactive login.
  • Check that the URL returns an image format accepted by the provider, not an HTML error page or a redirect to a sign-in form.
  • For private or recurring assets, use the provider’s documented upload or reusable-asset feature.
  • Use a data URI only when the selected API explicitly supports it and you have checked request-size limits. PDFSpark documents data URI and external URL support; that behavior should not be generalized to other services.

An <img> element and a CSS background-image are different cases. Ordinary image loading does not necessarily mean backgrounds will print. HTMLPDF documents image loading separately from a background-print option, and PDF.co exposes a printBackground control.

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

Example HTML with robust image references

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <style>
    @page { size: A4; margin: 18mm; }
    body { font-family: Arial, sans-serif; }
    .hero { width: 100%; height: auto; }
    .cover { background: url("https://static.example.com/cover.jpg") center/cover no-repeat; }
  </style>
</head>
<body>
  <h1>Quarterly report</h1>
  <img class="hero" src="https://static.example.com/chart.png" alt="Revenue chart">
  <div class="cover">Summary</div>
</body>
</html>

Before submitting, request each image URL from an environment that resembles the provider’s network and inspect the status, content type, redirects, and access requirements.

Control rendering instead of relying on defaults

Defaults differ, so set the options that matter to your layout.

Print or screen styles

Print CSS can intentionally hide navigation, change colors, and alter spacing. HTMLPDF documents an option to use print media stylesheets. If your design depends on screen styles, select the provider’s screen-media behavior instead and test backgrounds separately.

Page geometry

Choose paper size or explicit dimensions, orientation, viewport, and margins. Viewport width affects responsive breakpoints; paper size and margins affect pagination. PDF.co documents page, margin, header, and footer settings, and notes that margins must leave room for header or footer content.

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

Backgrounds and links

Enable background printing when color blocks or CSS backgrounds carry meaning. Confirm whether links, outlines, and other PDF metadata are supported and enabled by the provider.

JavaScript and waiting

Pages that inject images or text after load need JavaScript execution and a wait strategy. PDFSpark documents JavaScript rendering with a network-idle example; HTMLPDF documents JavaScript and a configurable delay. Use a selector wait when a known element signals readiness, a delay for predictable animations, or network-idle when all required requests settle. These controls are provider-specific.

Build the request and handle the response

Every service has its own endpoint, authentication, request encoding, and response contract. Some return PDF bytes synchronously; others return a job or an asset reference. Confirm the current API reference before coding.

Generic application flow

  1. Build the HTML or select the URL/file input.
  2. Validate every image and stylesheet reference from the renderer’s perspective.
  3. POST the input with credentials and explicit page, print, background, margin, and wait settings.
  4. Check the HTTP status and response content type.
  5. Write or stream PDF bytes only for a successful PDF response; otherwise parse and log the provider’s error body.
  6. Open representative PDFs and check images, page breaks, fonts, backgrounds, links, headers, and footers.

cURL pattern

curl -X POST "https://provider.example/v1/pdf" 
  -H "Authorization: Bearer $API_TOKEN" 
  -H "Content-Type: application/json" 
  --data @request.json 
  --output result.pdf

The URL above is only a shape, not a universal endpoint. Adobe’s documented REST example uses API-key and bearer authorization, an asset ID, page layout, and a wait setting. HTMLPDF documents a POST that submits a URL and writes the successful response to a PDF file. Adapt the endpoint and field names to the service you selected.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Python response validation

import requests

payload = {
    "url": "https://example.com/report",
    "print_media": True,
    "print_background": True,
    "wait": {"selector": "#report-ready"},
    "margin": "18mm"
}

r = requests.post(
    "https://provider.example/v1/pdf",
    headers={"Authorization": f"Bearer {TOKEN}"},
    json=payload,
    timeout=120,
)
r.raise_for_status()
content_type = r.headers.get("content-type", "")
if "pdf" not in content_type.lower():
    raise RuntimeError(f"Expected PDF, got {content_type}")
with open("result.pdf", "wb") as f:
    f.write(r.content)

Asynchronous jobs

For large documents or bulk workloads, a provider may return a job identifier instead of PDF bytes. Poll according to its documented schedule or configure its webhook mechanism. Store an idempotency key if offered, and treat a completed job as untrusted until you verify the downloaded content type and PDF integrity.

Diagnose missing images and layout defects

Images are blank or broken

  • Cause: relative URL, private host, expired signed URL, or an image request returning HTML.
  • Fix: use an absolute reachable URL, upload/package the asset, or use a documented data URI. Extend the signed URL lifetime beyond the render window.

Images appear intermittently

  • Cause: JavaScript has not finished, lazy loading waits for scrolling, or the service captured before network activity settled.
  • Fix: enable JavaScript, wait for a selector or network idle, and use a full-page capture or provider option that loads lazy images.

CSS backgrounds are missing

  • Cause: print backgrounds are disabled or the CSS image request is inaccessible.
  • Fix: enable the provider’s background-print option and verify the background URL independently.

Content is clipped or breaks badly

  • Cause: viewport, paper size, or margins do not match the responsive layout; fixed-height containers prevent natural pagination.
  • Fix: set viewport and page dimensions explicitly, increase margins, remove fixed heights, and add print-specific CSS.

The response is not a PDF

  • Cause: authentication or validation failed and the body contains a JSON or HTML error.
  • Fix: check status and content type before writing the file, log the error body securely, and correct credentials or field names.

Compare APIs on the details that affect your document

Question Why it matters
Does it accept HTML, URL, file, or archive? Determines how you package templates and private assets.
Can it fetch external, inline, or uploaded images? Controls whether protected and reusable resources render.
Does it run JavaScript and support waits? Needed for client-rendered text and lazy images.
Can you set viewport, paper, orientation, margins, backgrounds, headers, and footers? These settings determine pagination and visual fidelity.
What is the integration contract? Authentication, synchronous versus asynchronous delivery, retries, and error parsing differ.

Do not choose on unsupported claims about speed, reliability, or price. Comparable performance tests and service-level guarantees are not established here; validate your own representative pages.

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

Or skip the browser setup

ScreenshotNeo can capture a URL as a PDF through one API request, so you do not have to maintain a browser renderer. It accepts cookie and consent banners like a visitor, then removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing result in headers.

For a URL-based document, use the request shown in the ScreenshotNeo documentation and select PDF output according to its current format parameter:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

The same endpoint also supports full-page capture, custom CSS and JavaScript, waits, device and viewport settings, cookies, headers, geolocation, PDF paper and margin controls, bulk capture, caching, signed links, asynchronous jobs, and an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. Use the documented PDF output setting rather than assuming the example’s .webp filename.

Python

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)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

The Free plan includes 1,000 shots per month without a card. Paid plans start at $5 for 3,000 shots; every feature is included on every plan. Create a free ScreenshotNeo account.

Frequently Asked Questions

Can an API convert a page that requires a login?

Only if the provider supports the required cookies, headers, authorization, or uploaded assets and its terms permit that access. A normal browser session is not automatically available to a remote renderer.

Should I inline every image as a data URI?

No. Inline data can simplify access but increases request size and is supported only by some services. Use hosted or uploaded assets when the provider documents them.

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

How can I test PDF output safely?

Use representative pages containing remote images, lazy content, backgrounds, long tables, and headers or footers, then inspect both the visual pages and the response metadata.

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.