To convert a webpage URL to PDF with DocRaptor, send a JSON POST request to https://api.docraptor.com/docs with document_url set to the page address and type set to pdf. Authenticate with your DocRaptor API key as the HTTP Basic Auth username and a blank password. A successful synchronous request returns PDF bytes, which your application should save or stream as a file.
Make a URL-to-PDF request
The current request uses type; older integrations may use document_type, but new code should use the current name. Keep the API key on a server you control rather than embedding it in browser code.
| # | Preview | Product | Price | |
|---|---|---|---|---|
| 1 |
|
PDF Explained: The ISO Standard for Document Exchange | $14.41 | Buy on Amazon |
| 2 |
|
Adobe Acrobat 6 PDF For Dummies | $13.00 | Buy on Amazon |
| 3 |
|
Debugging: The 9 Indispensable Rules for Finding Even the Most Elusive Software and Hardware... | $13.39 | Buy on Amazon |
As an Amazon Associate I earn from qualifying purchases.
cURL
Set DOCRAPTOR_API_KEY in your environment before running this command. The example enables test mode so you can inspect the PDF; test output is watermarked.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
curl --user "$DOCRAPTOR_API_KEY:"
--fail --silent --show-error
--header "Content-Type: application/json"
--data '{"test":true,"type":"pdf","document_url":"https://example.com/page"}'
https://api.docraptor.com/docs
--output page.pdf
After verifying the result, remove "test":true for an unwatermarked production PDF. DocRaptor’s API overview describes the JSON POST endpoint at https://docraptor.com/documentation/api; the API reference documents request fields and rendering options at https://docraptor.com/documentation/api#doc.
#1 Best Overall
Python
Use a binary response and write its content directly to a file. Install the dependency with python -m pip install requests. Set DOCRAPTOR_API_KEY in the environment first.
import os
import requests
api_key = os.environ["DOCRAPTOR_API_KEY"]
response = requests.post(
"https://api.docraptor.com/docs",
auth=(api_key, ""),
headers={"Content-Type": "application/json"},
json={
"type": "pdf",
"document_url": "https://example.com/page",
"test": True,
},
timeout=120,
)
response.raise_for_status()
with open("page.pdf", "wb") as pdf_file:
pdf_file.write(response.content)
For production, change "test": True to False or omit it. The official Python tutorial covers HTML-to-PDF setup and says paid plans start at $15/month; verify current pricing on DocRaptor’s site before choosing a plan: https://docraptor.com/documentation/python.
Node.js
This example uses Node’s built-in fetch and writes the response bytes to a file. It requires a Node version with global fetch support. Set the key in DOCRAPTOR_API_KEY.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallimport { writeFile } from "node:fs/promises";
const apiKey = process.env.DOCRAPTOR_API_KEY;
if (!apiKey) throw new Error("Set DOCRAPTOR_API_KEY first");
const response = await fetch("https://api.docraptor.com/docs", {
method: "POST",
headers: {
"Authorization": `Basic ${Buffer.from(`${apiKey}:`).toString("base64")}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
type: "pdf",
document_url: "https://example.com/page",
test: true,
}),
});
if (!response.ok) {
const errorBody = await response.text();
throw new Error(`DocRaptor returned HTTP ${response.status}: ${errorBody}`);
}
await writeFile("page.pdf", Buffer.from(await response.arrayBuffer()));
Remove test: true for an unwatermarked production document. Don’t treat the successful body as JSON or text: it is the PDF data.
Rank #2
Choose URL input, PDF output, and authentication
- Use
document_urlwhen DocRaptor should fetch a webpage. The API also supportsdocument_contentfor inline document content, but that is a different input workflow. - Set
typetopdfto request a PDF. The API reference notesdocument_typeas a name used by older integrations. - Authenticate with HTTP Basic Auth, using your API key as the username and an empty password. DocRaptor identifies this as its preferred REST authentication method.
For a synchronous request, check the HTTP status before saving the response. A successful response contains binary PDF data. DocRaptor says errors return an XML error message; do not write that error body to a file with a .pdf extension.
Test safely, then make an unwatermarked PDF
Set test: true while developing or adjusting a document. Test PDFs carry a watermark, so remove the flag or set it to false when the final file must be unwatermarked. The official URL-to-PDF and Python documentation describe test mode and its watermark: https://docraptor.com/documentation/try-it-out and https://docraptor.com/documentation/python.
The tutorial pages show a public test key for test-mode use. Treat that as a testing convenience, not a production credential. Store your own live key in server-side configuration or a secrets manager, and make DocRaptor requests from your backend. DocRaptor’s general documentation warns that client-side code exposes the API key: https://docraptor.com/documentation.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Enable JavaScript only if the page needs it
JavaScript rendering is disabled by default, which avoids rendering work when the page is already available as HTML. If the URL depends on client-side JavaScript—for example, to populate a chart or page content—add "javascript": true to the JSON request.
Rank #3
- Used Book in Good Condition
DocRaptor’s API reference describes its JavaScript engine and a completion signal, docraptorJavaScriptFinished(), for delayed or asynchronous code. Avoid enabling both available JavaScript engines together unless your particular document requires that arrangement; the reference warns that code may be evaluated twice. See the API reference and the JavaScript tutorial.
Handle the response and choose a request mode
Synchronous PDF bytes
The examples above use the normal synchronous response: after a successful request, save or stream the response body as binary data. DocRaptor’s API overview says the X-DocRaptor-Num-Pages response header contains the PDF page count. The same overview documents the endpoint and response modes at https://docraptor.com/documentation/api.
Hosted and asynchronous documents
DocRaptor documents alternatives to receiving the PDF bytes directly: hosted documents return a public URL, while asynchronous document requests return a status_id that you use to retrieve the document. These are distinct response flows from the synchronous file-writing examples here; select one only if your application’s delivery or processing pattern calls for it. Refer to the API overview for the corresponding behavior.
Troubleshoot common failures
- The saved file is XML or is not a valid PDF: The request may have failed and returned DocRaptor’s XML error body. Check the HTTP status and inspect the response before writing it as a PDF.
- DocRaptor cannot download the page: The API reports errors such as “Error downloading document content from supplied url.” Confirm the URL is correct and reachable by DocRaptor, and that it serves the intended page rather than an access-denied or unrelated response.
- The PDF is missing charts or other page content: If the page creates that content in the browser, JavaScript is likely required. Enable
javascript: trueand, for delayed work, use the documented completion signal where appropriate. - The PDF has a watermark: This is expected when test mode is enabled. Remove
test: truefor the production request. - The request is rejected as unauthorized: Check that Basic Auth uses the API key as username and a blank password, and that the key is the correct account credential.
- The API key appears in browser source: Move the request to a server-side agent. A key embedded in a public website can be exposed to visitors.
Or skip the browser setup
If your goal is a clean screenshot or PDF capture of a URL rather than DocRaptor’s document-conversion workflow, ScreenshotNeo provides a one-request screenshot API. For example, this cURL request saves a WebP screenshot:
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 API documentation for request options. It accepts cookie or consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status. Its MCP server gives AI agents tools to take screenshots, get page information, and capture PDFs.
ScreenshotNeo’s free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo free.
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.




