apyhub
Engineering · Html

HTML to PDF API: What It Does and Why Teams Use One

01Introduction

An HTML to PDF API takes a web page or a block of markup and returns a PDF file. You send a URL or the HTML itself, and you get back a document you can save, email, or attach.

It is one of the most common jobs in software, because almost every product eventually has to hand a customer a file. The content already exists as a page somebody designed and approved. It has to leave the product as a PDF.

02What it is used for

The same request shape covers a lot of ground.

  • Invoices and receipts. The template already exists as a page in your app. The PDF matches what the customer sees in their account.
  • Statements and payslips. Generated on a schedule, in volume, usually looking identical every month.
  • Order confirmations and shipping documents. Triggered by an event and emailed as an attachment.
  • Contracts and agreements. Rendered from a template, sent for signature, filed afterward.
  • Reports and data exports. A dashboard view a customer wants to keep, print, or forward to their accountant.
  • Certificates and tickets. Short documents generated in bulk where the layout has to be exact every time.
  • Archived pages. A snapshot of a page as it looked on a date, for compliance or records.

The pattern underneath all of them is the same. You already have the content as HTML. You need it as a file, on demand, without a human clicking print.

03Why teams stop building it themselves

Rendering HTML to PDF yourself is easy to start and expensive to keep.

wkhtmltopdf is the most widely deployed tool for the job, and it stopped moving years ago. Its main repository was archived by the owner on January 2, 2023 and is now read-only, and the whole GitHub organization was marked as archived in July 2024. No commits, no releases, no security patches.

That has a consequence you inherit. CVE-2022-35583 describes a server-side request forgery in version 0.12.6, and Ubuntu's security tracker notes no upstream fix was available as of July 2023, because the project treats it as a problem for the applications passing in unsanitized HTML. Either way, the mitigation is yours to build and keep building.

Headless Chrome through Puppeteer is the other common route. The output is excellent, because it is Chrome. It also means running a browser in production, with the container size, the memory ceiling, and the cleanup that comes with it.

An API removes both problems. Nothing to install, nothing to patch, nothing to keep alive. One call, one file back.

04The options on ApyHub

The ApyHub catalog has five APIs for this, from three providers. They differ mainly in what you send them and how much control you get over the page.

APIYou sendNotableAtomsProvider
Convert HTML Content to PDFAn HTML stringCheapest route from template to file50ApyHub
Convert Webpage to PDFA public URLBuilt for capturing and archiving pages50ApyHub
Convert HTML to PDFA URL, base64, or a file uploadMost flexible on input, accepts uploads to 100MB100ApyHub
Convert URL/HTML to PDFA URL or HTMLAppends existing PDFs to the output in the same call100Dosvak LLC
Convert and Format raw HTML to PDFAn HTML stringFive page sizes, per-side margins, background printing100Website Intelligence

Two of those are worth calling out, because they do something the others do not. Convert URL/HTML to PDF is the only one that merges, which matters when an invoice ships with terms attached or a report ships with a fixed appendix. Convert and Format raw HTML to PDF gives the most control over the page itself, which matters when a wide table needs A3 or a design depends on background fills.

Every API on ApyHub has an API playground on its service page. Send a real request, look at the real response, then decide. No code required to find out whether a service handles your document, and the playground shows you the exact endpoint URL to drop into the call above.

05One subscription, and agents can call it too

All five sit under one subscription. Atoms are ApyHub's usage unit and they spend against any service in the catalog, so trying a different conversion costs a different endpoint and nothing else. No second vendor, no second key, no per-API plan to upgrade.

Requests route through the ApyHub gateway, which runs in EU and US regions, so EU workloads stay on EU infrastructure.

All five are also available over ApyHub MCP, on every plan. MCP is not a separate product or an add-on. A call an agent makes over MCP spends the same atoms as a call from your own code, so your usage stays one pool no matter what is doing the calling. Every endpoint in the catalog is MCP-ready by default, so an agent can search the catalog while it works, find the conversion it needs, and call it. No wrapper, no tool definition, nothing written in advance. It works with Claude Code, Claude Desktop, Cursor, ChatGPT, Codex CLI, VS Code, and any other MCP client.

That fits document work well. An agent building a report often discovers partway through that it needs a PDF, and the render becomes a step in a plan rather than a feature somebody scoped in advance.

Read more about ApyHub MCP →

06Conclusion

Turning HTML into a PDF is a small job that every product needs and nobody wants to own. An API makes it one call, with no renderer to maintain and no browser to keep alive. Try the one that matches your input in the playground, then wire it in.

Browse the file conversion catalog →

07FAQ

What is an HTML to PDF API? A service that takes a web page URL or a block of HTML and returns a PDF file. One HTTPS call, no renderer to install.

What is it used for? Invoices, receipts, statements, payslips, order confirmations, contracts, certificates, tickets, reports, and archived pages. Anything your product renders as a page and has to hand over as a file.

Can I use my existing invoice template? Yes, and it is the usual reason to pick this route. The template already exists as HTML and CSS somebody approved, so the PDF matches the page your customer sees.

Which one should I start with? Convert HTML Content to PDF if you have the markup, or Convert Webpage to PDF if you have a URL. Both cost 50 atoms. Move up only when you need merging, more page control, or an upload.

Can I attach existing PDFs to the output? Yes, with Convert URL/HTML to PDF. Pass the PDF links and they are appended after the render, in the same call. This is the usual way to put terms after an invoice or an appendix after a report.

Can I control page size and margins? Yes. Convert and Format raw HTML to PDF offers five page sizes and all four margins in CSS units, and can print background colors and graphics.

Can I test it before writing code? Yes. Every API on ApyHub has an API playground on its service page, so you can send a real request and see the response in your browser.

Do I need to install anything? No. There is no renderer to install and no browser to run. Your application makes one HTTPS call.

Can an AI agent call these APIs? Yes, over ApyHub MCP, which works on every plan. An agent can find the right service and call it mid-task without anyone writing a wrapper first.

Do agent calls cost extra? No. MCP follows your normal plan. A call over MCP spends the same atoms as a call from your own code.

Does my data leave the EU? The gateway runs in EU and US regions, and EU traffic stays on EU infrastructure. The MCP server has separate EU and US endpoints.

What does it cost? 50 or 100 atoms per call depending on the service. One subscription covers every API in the catalog, so there is no per-API plan to upgrade.

Is there a free tier? Yes, no card required. You get catalog access on signup and can test against your own templates first.

What else can I do with documents on ApyHub? Convert PDF to Word, Word to PDF, spreadsheets to PDF, and images between formats, plus merging, splitting, compressing, and watermarking. Most document workflows chain two or three of these together.

08About ApyHub

ApyHub is a curated API catalog and the trusted operational layer between your application and the services it depends on. One subscription, denominated in atoms, covers the whole catalog rather than a separate plan per API. Every service is evaluated before listing and carries machine-readable certification covering data handling, retention, and alignment with GDPR, SOC 2, and ISO 27001, so compliance is something your systems and your auditors can read rather than something you rediscover after integration. Every endpoint is MCP-ready by default, which means AI agents can discover, evaluate, and call APIs without hand-written wrappers or tool definitions.

The catalog currently spans 1,500+ endpoints across 400+ services, with new APIs and providers onboarded continuously, and runs across EU and US regions. ApyHub is headquartered in Amsterdam, with offices in the Netherlands, Greece, and India, and serves 65,000+ developer workspaces every month. The free tier requires no card.

Building an API of your own? Publish it on ApyHub and reach the developers and agents already calling the catalog.