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C9TCi9QYXJlbnQgNyAwIFI+PgplbmRvYmoKNyAwIG9iago8PC9UeXBlIC9QYWdlcwovQ291bnQgMQovS2lkcyBbMiAwIFJdPj4KZW5kb2JqCjggMCBvYmoKPDwvVHlwZSAvQ2F0YWxvZwovUGFnZXMgNyAwIFIKL1ZpZXdlclByZWZlcmVuY2VzIDw8L1R5cGUgL1ZpZXdlclByZWZlcmVuY2VzCi9EaXNwbGF5RG9jVGl0bGUgdHJ1ZT4+Pj4KZW5kb2JqCjkgMCBvYmoKPDwvTGVuZ3RoMSA3MjgwCi9GaWx0ZXIgL0ZsYXRlRGVjb2RlCi9MZW5ndGggNDQ0OT4+IHN0cmVhbQp4nK04C3Qb1ZX3zuhrW9bIsS3LitAoE5sE2ZET2QkmH09kSf7iv0FSQiz5kzhpHDu2Ez6BxksJmyMSEqC0UNiGw0I3WwIZJykx/ZDw23PaU7bdhZ7y8ybQcOgpsOFTaCFY...",
"_note": "Response truncated for documentation purposes"
}
curl --location --request POST 'https://zylalabs.com/api/13987/html+to+pdf+api/33873/convert+html+or+any+web+page+url+to+a+pdf+document' --header 'Authorization: Bearer YOUR_API_KEY'
--data-raw '{
"html": "Invoice #42
Hello world
",
"output": "json"
}'
After signing up, every developer is assigned a personal API access key, a unique combination of letters and digits provided to access to our API endpoint. To authenticate with the HTML to PDF API simply include your bearer token in the Authorization header.
| Header | Description |
|---|---|
Authorization
|
Required
Should be Bearer access_key. See "Your API Access Key" above when you are subscribed.
|
No long-term commitment. Upgrade, downgrade, or cancel anytime. Free Trial includes up to 50 requests.
Convert HTML or any web page to a pixel-perfect PDF with headless Chromium: page size, margins, headers and footers, compression.
By default the response body is the PDF file itself (application/pdf). Set "output" to "json" to receive a JSON object with filename, content_type, size and data, where data is the PDF encoded in base64.
Yes. options.format (A3, A4, A5, Letter, Legal), landscape, print_background, margin_mm, scale and wait_ms for pages that need extra time to render. Set "compression" to true to recompress the PDF with Ghostscript: the smaller of the two files is returned.
No. Documents are rendered in memory and discarded after the response. Each request uses an isolated browser context, and URLs that point to private or internal networks are refused.
Raw HTML (with inline CSS, images and web fonts) or any public URL. Pages are rendered in a headless browser engine, so modern CSS, SVG, web fonts and JavaScript-generated content look exactly as in a desktop browser.
Fonts and images are awaited automatically. For pages that load content with JavaScript, set wait_ms to wait a little longer before the PDF is printed. URLs must be reachable from the public internet.
The endpoint returns a PDF document as the response body by default. If the "output" parameter is set to "json," it returns a JSON object containing the filename, content_type, size, and base64-encoded PDF data in the "data" field.
The JSON response includes four key fields: "filename" (the name of the PDF file), "content_type" (the MIME type, typically application/pdf), "size" (the file size in bytes), and "data" (the base64-encoded PDF content).
Users can customize requests by providing parameters such as "html" or "url" for content, "compression" for file size reduction, "output" for response format, and layout options like "format," "landscape," and "margin_mm" to control the PDF appearance.
Accepted parameter values include "html" (raw HTML content), "url" (public web page), "compression" (true/false), "output" (json/binary), and layout options like "format" (A3, A4, etc.), "landscape" (true/false), and "margin_mm" (numeric values).
The response data is organized based on the output format. For binary output, it is a direct PDF file. For JSON output, it is structured as a key-value pair object containing "filename," "content_type," "size," and "data."
Typical use cases include generating reports, invoices, or documentation from HTML content, converting web pages into PDFs for archiving, and creating printable versions of online content while preserving layout and design.
Users can save the PDF file directly from the binary response or decode the base64-encoded data from the JSON response to create a PDF file programmatically. This allows for integration into applications or workflows that require PDF generation.
Users can include raw HTML with inline CSS, images, and web fonts. The API supports modern web technologies, allowing for accurate rendering of complex layouts, styles, and JavaScript-generated content as seen in a desktop browser.
To obtain your API key, first sign in to your account and navigate to the API you want to use. From the API's Pricing section, choose a plan and complete the subscription process. Once subscribed, return to the API page and you will see your API Access Key displayed at the top of the documentation page. You can use this key to authenticate your requests.
You can’t switch APIs during the free trial. If you subscribe to a different API, your trial will end and the new subscription will start as a paid plan.
The free trial lasts for 7 days and allows you to make up to 50 API requests.
No, the free trial is available only once, so we recommend using it on the API that interests you the most. Most of our APIs offer a free trial, but some may not include this option.
Yes. If the API offers a free trial, you will see a "Free 7-Day Trial" option in its Pricing section. The trial lasts for 7 days and allows up to 50 API requests, enabling you to evaluate the API before subscribing to a paid plan.
Zyla API Hub is like a big store for APIs, where you can find thousands of them all in one place. We also offer dedicated support and real-time monitoring of all APIs. Once you sign up, you can pick and choose which APIs you want to use. Just remember, each API needs its own subscription. But if you subscribe to multiple ones, you'll use the same key for all of them, making things easier for you.
You can monitor your API usage through the response headers included with every request:
x-zyla-api-calls-monthly-used: Shows the total number of API requests you have used during the current billing period.
x-zyla-api-calls-monthly-remaining: Shows the number of API requests you have remaining for the current billing period.
Yes, you can cancel your subscription at any time. Simply go to the Pricing section of the API you're subscribed to and click the "Unsubscribe" button.
Please note that upgrades, downgrades, and cancellations take effect immediately. Once your subscription is canceled, access to the service will end immediately, regardless of any remaining API calls in your quota.
Please have a look at our Refund Policy: https://zylalabs.com/terms#refund