Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →There is no universal HTML-to-PDF API key format. You create credentials with the provider you choose, then send them exactly as that provider documents—often in a custom header, sometimes as a token, and in Adobe’s REST example as a client ID plus bearer token. Keep the credentials on your server, submit the provider’s accepted HTML, URL, or file input, and handle the result as PDF bytes, a download URL, or an asynchronous job.
What an HTML-to-PDF API key actually is
An API key is a credential issued by a particular conversion service. It is not a standard that works across services. The name, header, prefix, expiration behavior, input fields, and response format all belong to the provider’s API.
| Provider documentation | Credential and header shown | Input or result model |
|---|---|---|
| pdfmyhtml | X-API-Key: YOUR_API_KEY |
Raw HTML or a URL; synchronous completion or an asynchronous job |
| HTML PDF API | Authentication: Token <token> |
One of url, file, or html; PDF endpoint returns PDF data |
| Adobe PDF Services | x-api-key plus Authorization: Bearer <token> |
REST operation with an uploaded asset and additional operation fields |
APIVoid’s reference also shows an X-API-Key pattern, but that does not make the pattern universal. Treat every endpoint as a separate contract.
1. Choose a provider and create credentials
Use the provider’s account or dashboard
Sign up with the service you intend to call and open its current API, developer, or credentials area. pdfmyhtml documents generating a key in its dashboard. HTML PDF API documents token authentication. Adobe’s HTML-to-PDF documentation uses a client ID and client secret, with an access token for the REST request.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →#1 Best Overall
Account eligibility, quotas, pricing, geographic availability, retention, and credential controls differ and are not interchangeable. Check the selected provider’s live account documentation before committing an integration.
Adobe is not a single-key example
Adobe’s documented REST pattern uses both a client ID in x-api-key and a bearer access token in Authorization. Its SDK example reads PDF_SERVICES_CLIENT_ID and PDF_SERVICES_CLIENT_SECRET from environment variables. Do not copy a one-key example and omit the token step when using Adobe.
2. Store the credential server-side
Put keys, client secrets, and bearer tokens in environment variables or your server’s secret manager. Do not hard-code them in a browser bundle, public Git repository, downloadable JavaScript, or HTML sent to users.
export PDFMYHTML_API_KEY='replace-with-your-key'
Your application can read that variable at request time. If a credential is exposed, use the provider’s current dashboard or account instructions to replace it; revocation and rotation controls vary by service.
- Give the secret only to the backend process that needs it.
- Keep it out of request logs, exception messages, screenshots, and support tickets.
- Use separate credentials for development and production when the provider supports that choice.
- Review the provider’s current limits and billing controls before sending bulk jobs.
3. Send HTML with pdfmyhtml
The following is a provider-specific example from pdfmyhtml. It posts JSON to https://api.pdfmyhtml.com/v1/html-to-pdf, authenticates with X-API-Key, and asks the service to wait for completion.
Rank #2
- Used Book in Good Condition
curl -X POST "https://api.pdfmyhtml.com/v1/html-to-pdf"
-H "Content-Type: application/json"
-H "X-API-Key: YOUR_API_KEY"
-d '{"html":"<h1>Hello World!</h1>","wait":true}'
With wait=true, the documented behavior is to wait and return a download URL. With wait=false, which the documentation describes as the default, the response provides a job ID that you must poll using pdfmyhtml’s job-status instructions.
Python request
import os
import requests
html = "<!doctype html><html><body><h1>Invoice</h1></body></html>"
r = requests.post(
"https://api.pdfmyhtml.com/v1/html-to-pdf",
headers={"X-API-Key": os.environ["PDFMYHTML_API_KEY"]},
json={"html": html, "wait": True},
timeout=90,
)
r.raise_for_status()
print(r.json()) # A completed response includes the provider's download information
Node.js request
const html = '<!doctype html><html><body><h1>Invoice</h1></body></html>';
const res = await fetch('https://api.pdfmyhtml.com/v1/html-to-pdf', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': process.env.PDFMYHTML_API_KEY
},
body: JSON.stringify({ html, wait: true })
});
if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);
console.log(await res.json());
4. Match the input mode your provider supports
Raw HTML
Send an HTML string when your application already has the markup. Include the CSS, fonts, images, and print rules your provider supports. Relative assets may require a base URL or absolute, reachable URLs; check the provider’s rendering rules rather than assuming a browser-like local filesystem.
A public URL
HTML PDF API documents a PDF endpoint that accepts one of url, file, or html. pdfmyhtml documents a separate URL workflow in addition to its HTML endpoint. A URL must be reachable by the provider’s renderer and may require authentication or special handling for private pages.
An uploaded file or archive
Use the provider’s documented multipart or asset-upload procedure when your document depends on local images, stylesheets, or multiple files. Adobe’s example first uses an uploaded asset ID and then supplies operation fields. The exact upload and conversion sequence is Adobe-specific.
5. Handle the response correctly
Do not assume every successful request contains PDF bytes. Depending on the service and processing mode, you may receive:
Rank #3
- PDF bytes that your server writes directly to a file.
- A download URL that your server fetches and stores.
- A job ID that your server polls until completion.
HTML PDF API’s example writes the returned PDF response to a file. pdfmyhtml’s wait=true flow returns download information, while its asynchronous flow returns a job ID. Follow the selected provider’s status, expiry, and download instructions.
response = requests.post(endpoint, ...)
response.raise_for_status()
content_type = response.headers.get("content-type", "")
if "application/pdf" in content_type:
with open("document.pdf", "wb") as output:
output.write(response.content)
else:
data = response.json()
# Inspect the provider-specific download URL or job ID.
Authentication examples that must not be mixed
These snippets show why copying headers between services fails:
- pdfmyhtml:
X-API-Key: YOUR_API_KEY. - HTML PDF API:
Authentication: Token <token>. - Adobe:
x-api-key: <client ID>andAuthorization: Bearer <access token>.
Header names are usually case-insensitive at the HTTP layer, but the required value format and required combination are not. An API key from one vendor cannot authenticate to another vendor’s endpoint.
Troubleshooting checklist
401 or 403 response
Check that the credential belongs to this provider, the header name and prefix exactly match its reference, and the server is actually loading the intended environment variable. For HTML PDF API, the reference identifies an invalid or missing token as an authentication failure. Other providers may use different status codes and messages.
400 or validation error
Verify the JSON or multipart content type, required field names, and mutually exclusive input choices. HTML PDF API requires one of url, file, or html, not an invented field name. pdfmyhtml’s HTML endpoint expects an html string.
Rank #4
A job never finishes
Confirm that you are polling the provider’s documented status endpoint with the returned job ID, using the required authentication. Respect provider timeouts and retry guidance; do not create unlimited duplicate jobs.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsThe PDF is blank or missing assets
Inspect the source HTML in a normal browser, replace inaccessible relative resources with reachable URLs where appropriate, and check whether the provider requires an uploaded file or archive. Private pages may need provider-supported headers or cookies.
The response is JSON instead of a PDF
That commonly means the service returned a job, an error, or a download URL. Log the status code and content type safely, parse JSON only when the content type indicates JSON, and follow the provider’s documented next step.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Reliability, performance, and cost decisions
Choose synchronous processing for short, interactive conversions when the provider documents a practical timeout. Choose asynchronous jobs for larger documents or batch work, then persist the job ID and retry polling with bounded delays. Cache identical source documents only if your privacy and freshness requirements allow it.
Do not publish a quota, price, retention period, regional guarantee, or performance number as a universal HTML-to-PDF fact. Those values change by provider, plan, and date. Verify them in the selected service’s current account and API pages.
Best Value
Or skip the browser setup:
If what you really need is a clean capture of a web page rather than a print-perfect HTML-to-PDF pipeline, ScreenshotNeo provides a website screenshot API and MCP server. A single request can return PNG, JPEG, WebP, or PDF:
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 the request options. Before capture it accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response reports the page verdict and billing status in X-Page-Verdict and X-Billed headers. Its MCP server includes take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.
ScreenshotNeo includes 1,000 screenshots per month free with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.
Provider-selection questions to answer before coding
- Does the service accept raw HTML, a public URL, an uploaded file, or several modes?
- Does authentication require one key, a prefixed token, or a client ID plus bearer token?
- Will success return bytes, a URL, or a job ID?
- How are private assets, fonts, cookies, JavaScript, and redirects handled?
- What are the current quota, pricing, data-retention, region, and rotation rules for your account?
Frequently Asked Questions
Where do I put an HTML-to-PDF API key?
Put it in the exact authentication header or parameter named by your provider. Examples include pdfmyhtml’s X-API-Key, HTML PDF API’s Authentication: Token format, and Adobe’s x-api-key together with a bearer Authorization header.
Recommended Free Tools
Can I use an API key from one PDF service with another?
No. Credentials are issued for a specific provider and endpoint; authentication schemes and token formats are provider-specific.
Should the key be sent from browser JavaScript?
Normally no. Keep it in server-side environment or secret-manager configuration so visitors cannot extract it.
What should I do if the API returns a job ID?
Persist the ID and use that provider’s documented status or polling endpoint until completion, then download the resulting PDF according to its response contract.
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.
Free tools Windows power users keep installed
One-click scans. No signup required.

