Install PDFCrowd’s Python client, create an authenticated HtmlToPdfClient, then call convertUrlToFile() to save a web page as a local PDF. Use convertUrl() instead if your application needs the PDF bytes, or convertUrlToStream() to write to a stream.
Install the PDFCrowd Python client
PDFCrowd’s official Python package wraps its HTML-to-PDF API. Install it with Python’s pip module:
As an Amazon Associate I earn from qualifying purchases.
python -m pip install pdfcrowd
The package registry lists version 6.7.2, released September 22, 2026. The PDFCrowd reference identifies client-library and converter versions separately, so a package release does not by itself establish a change to the converter’s default version. Check the current Python library reference for version-specific behavior.
Free tools Windows power users keep installed
One-click scans. No signup required.
Convert a URL and save the PDF to a file
Use convertUrlToFile(url, file_path) for the most direct script workflow. Replace the example credentials with your PDFCrowd username and API key before using this in production.
#1 Best Overall
import pdfcrowd
import sys
try:
client = pdfcrowd.HtmlToPdfClient("YOUR_USERNAME", "YOUR_API_KEY")
client.setContentViewportWidth("balanced")
client.convertUrlToFile("https://www.example.com", "example.pdf")
except pdfcrowd.Error as error:
sys.stderr.write(f"PDFCrowd error: {error}n")
raise
PDFCrowd’s guide provides demo / demo credentials for trying its examples, but they are not production credentials. For ongoing use, obtain your own credentials through a free trial or API license. See PDFCrowd’s Python setup guide for the account and quick-start details.
The URL conversion methods document HTTP and HTTPS addresses. The file path is where the resulting PDF is written; make sure the process has permission to create or overwrite a file there.
Rank #2
Choose how your application receives the PDF
Pick the conversion method based on what your program will do with the output:
| Method | Output | Use it when |
|---|---|---|
convertUrlToFile(url, file_path) |
Saves the PDF directly to the specified path. | A script or scheduled job should create a local PDF file. |
convertUrl(url) |
Returns PDF bytes. | You need to process the PDF in memory, return it from a web endpoint, or pass it to another component. |
convertUrlToStream(url, out_stream) |
Writes the PDF to a supplied output stream. | Your application already manages a stream and should write into it. |
These methods are documented in PDFCrowd’s Python examples and library reference.
Return PDF bytes
import pdfcrowd
client = pdfcrowd.HtmlToPdfClient("YOUR_USERNAME", "YOUR_API_KEY")
pdf_bytes = client.convertUrl("https://www.example.com")
with open("example.pdf", "wb") as pdf_file:
pdf_file.write(pdf_bytes)
Write to a stream
import io
import pdfcrowd
client = pdfcrowd.HtmlToPdfClient("YOUR_USERNAME", "YOUR_API_KEY")
pdf_stream = io.BytesIO()
client.convertUrlToStream("https://www.example.com", pdf_stream)
pdf_bytes = pdf_stream.getvalue()
Adjust responsive layout and printed pages
A web page’s responsive layout can depend on the viewport width used during conversion. PDFCrowd’s examples show setContentViewportWidth("balanced") and a specific width such as 960px. The examples also document page size, orientation, and margins. There is no single setting established as best for every website, so choose based on how the target page responds and what the PDF needs to show.
client.setContentViewportWidth("960px")
client.setPageSize("A4")
client.setOrientation("landscape")
client.setMarginTop("10mm")
client.setMarginBottom("10mm")
Use a wider viewport if a responsive page collapses into a narrow mobile-style layout; choose page orientation and margins to suit the content and print use. Confirm the available method names and accepted values in the PDFCrowd Python examples, since layout controls do not guarantee identical results across sites.
Handle and diagnose conversion errors
Catch pdfcrowd.Error so API failures are visible and can be logged, reported, or re-raised. The first example above reports the exception and re-raises it, ensuring a calling process does not silently treat a failed conversion as successful.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
For deeper diagnostics, PDFCrowd’s examples document setDebugLog(True) and accessors for a debug-log URL, consumed and remaining credits, job ID, page count, and output size. Use the current Python examples to confirm accessor names and add the diagnostics relevant to your application.
Best Value
- The request raises a PDFCrowd error: Catch and log the exception text. Check that the credentials are your own valid account credentials, the URL is reachable over HTTP or HTTPS, and your account can make the conversion.
- The PDF layout is too narrow, wide, or clipped: Adjust the content viewport width, page size, orientation, or margins, then inspect the output. The right values depend on the page’s responsive design and the desired PDF.
- The output file is missing: Check the destination path and the process’s write permissions. With
convertUrlToFile(), the path is the target for the generated PDF. - You need to investigate a failed or unexpected job: Enable debug logging and inspect the documented debug-log URL and job or output metadata.
Or skip the browser setup
If your goal is a clean screenshot rather than a paginated PDF, ScreenshotNeo can return a webpage capture through one API request. It is a screenshot API, not a replacement for PDFCrowd’s URL-to-PDF conversion.
Install the Python dependency if needed with python -m pip install requests, then use the documented call below. Replace the URL to capture and set your API key. See the ScreenshotNeo API documentation for request options and response details.
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)
ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture. Bot checks, blank pages, failed loads, and cache hits are not billed. It also provides an MCP server for AI agents, with tools including take_screenshot, get_page_info, and capture_pdf. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
Frequently Asked Questions
Can PDFCrowd convert a URL that does not start with HTTP or HTTPS?
The documented URL protocols for the Python URL-conversion methods are HTTP and HTTPS.
Does the PDFCrowd demo account work for production conversions?
No. The demo credentials are for trying examples; production use requires your own PDFCrowd credentials.
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.




