Install PDFCrowd’s PHP client with Composer, create an HtmlToPdfClient using your PDFCrowd username and API key, then choose a conversion method for a URL, HTML string, or file. You can save the PDF to disk or return its bytes for a download. The examples below show each path, resource handling, layout options, and error handling.
Install and initialize the PHP client
From your project directory, install the official client:
As an Amazon Associate I earn from qualifying purchases.
composer require pdfcrowd/pdfcrowd
Load Composer’s autoloader and create the client with your PDFCrowd username and API key. The documentation uses demo credentials in examples; use your own credentials for production and keep them in environment variables or another secret configuration rather than committing them to source code. See the PDFCrowd PHP guide.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minute<?php
require __DIR__ . '/vendor/autoload.php';
$username = getenv('PDFCROWD_USERNAME');
$apiKey = getenv('PDFCROWD_API_KEY');
$client = new PdfcrowdHtmlToPdfClient($username, $apiKey);
Choose the right HTML input method
Use the input that matches where your page comes from. URL conversion is convenient for a page already available on the web; string conversion gives you control over application-rendered HTML; file conversion works with an existing HTML document or a packaged set of local assets.
#1 Best Overall
- Convert your PDF files into Word, Excel & Co. the easy way
- Convert scanned documents thanks to our new 2022 OCR technology
- Adjustable conversion settings
- No subscription! Lifetime license!
- Compatible with Windows 11, 10, 8.1, 7 - Internet connection required
| Input | Save PDF directly | Return PDF bytes | Best fit |
|---|---|---|---|
| Web page URL | convertUrlToFile($url, $path) |
convertUrl($url) |
A page reachable by PDFCrowd’s servers |
| HTML string | convertStringToFile($html, $path) |
convertString($html) |
Markup generated from your PHP application or template |
| Local HTML file or archive | convertFileToFile($input, $path) |
Use the corresponding in-memory file method | An existing document and its bundled resources |
Convert a reachable web page
Use convertUrlToFile when you want the client to write the result to a path:
$url = 'https://example.com/report';
$client->convertUrlToFile($url, __DIR__ . '/report.pdf');
To keep the PDF in memory instead, call convertUrl. Its return value is PDF bytes, which you can send in an HTTP response or write to storage.
Convert application-generated HTML
Pass a complete HTML string to convertStringToFile to save directly, or use convertString to get bytes:
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #2
- Convert over 50 document file formats.
- Preview your files from Doxillion before converting them.
- Use batch conversion to convert thousands of files at once.
- Enjoy an easy-to-use, intuitive interface with a Drag and Drop file option.
- Burn your converted or original files directly to disc.
$html = '<!doctype html><html><head><meta charset="utf-8"></head>'
. '<body><h1>Invoice</h1><p>Invoice content</p></body></html>';
$pdfBytes = $client->convertString($html);
if (file_put_contents(__DIR__ . '/invoice.pdf', $pdfBytes) === false) {
throw new RuntimeException('Could not write the PDF file.');
}
For content that uses relative image, stylesheet, or script paths, provide a suitable <base href="…"> in the document or use absolute URLs. Any referenced remote assets must be reachable to the conversion service.
Convert a local HTML file and its assets
For a standalone HTML file, use convertFileToFile($input, $path). If the document depends on local CSS, JavaScript, or images, package the HTML and its assets in a supported ZIP or tar archive and preserve their relative paths. If the archive contains multiple HTML files, select the main document using the documented setting. PDFCrowd’s HTTP API guide describes input requirements and resource handling.
$client->convertFileToFile(
__DIR__ . '/bundle.zip',
__DIR__ . '/bundle.pdf'
);
Configure the PDF before conversion
Set options on the client before calling the conversion method. The PHP guide and PHP examples document controls including page size, margins, orientation, headers and footers, content viewport width, scale, print media, custom CSS, custom JavaScript and readiness, and conversion of a particular element. Use the option names and accepted values in the client documentation for the option you need.
Rank #3
- EDIT text, images & designs in PDF documents. ORGANIZE PDFs. Convert PDFs to Word, Excel & ePub.
- READ and Comment PDFs – Intuitive reading modes & document commenting and mark up.
- CREATE, COMBINE, SCAN and COMPRESS PDFs
- FILL forms & Digitally Sign PDFs. PROTECT and Encrypt PDFs
- 1 Year License for 1 Windows & 2 Mobile (Android and/or iOS) devices.
For example, the official guide shows a balanced viewport setting. That is an explicitly requested setting, not a claim about the API’s default. Set only the options your document requires, then invoke the desired conversion method.
Return a PDF as a web download
For a browser download, handle the conversion request with POST, return a PDF content type, and emit the PDF bytes only after conversion succeeds. Catch PdfcrowdError so a conversion or validation failure does not produce a partial or mislabeled PDF response. The official website-response example demonstrates this pattern.
<?php
require __DIR__ . '/vendor/autoload.php';
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
http_response_code(405);
header('Allow: POST');
exit('Use POST to generate the PDF.');
}
try {
$client = new PdfcrowdHtmlToPdfClient(
getenv('PDFCROWD_USERNAME'),
getenv('PDFCROWD_API_KEY')
);
// Replace with HTML rendered and validated by your application.
$html = '<!doctype html><html><body><h1>Report</h1></body></html>';
$pdfBytes = $client->convertString($html);
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="report.pdf"');
header('Content-Length: ' . strlen($pdfBytes));
echo $pdfBytes;
} catch (PdfcrowdError $error) {
http_response_code(502);
header('Content-Type: text/plain; charset=utf-8');
echo 'PDF conversion failed.';
// Log the exception details server-side; do not expose credentials.
}
Do not print debug messages, warnings, or HTML before the PDF headers and bytes. In a framework, use its response object and error handling rather than mixing output with the PDF stream.
Rank #4
- Perfect Adobe Acrobat Pro alternative – lifetime license for Windows 10 and 11.
- EDIT text, images, pages, hyperlinks, designs in PDF documents. ORGANIZE PDFs.
- READ and Comment on PDFs – Intuitive reading modes & document commenting and mark up tools!
- CREATE, COMBINE, SCAN and COMPRESS PDFs.
- FILL forms & Digitally Sign PDFs. Work with Digital certificates
Save the result to storage
The file-output methods are simplest when the destination path is known. If using a bytes-returning method, check that writing succeeded, as in the string example above. Ensure the PHP process can write to the destination, and avoid using a client-provided filename as a filesystem path without validation.
HTTP API version note
PDFCrowd’s HTTP documentation specifies POST https://api.pdfcrowd.com/convert/24.04/, HTTP Basic authentication using the PDFCrowd username and API key, and form fields, with multipart requests for uploads. A successful response contains PDF bytes. This is the version documented at the HTTP API guide; it is not established here as the newest available version. Keep the endpoint version explicit and review PDFCrowd’s versioning documentation before changing it. If you use the PHP client, follow its documented methods rather than constructing the raw HTTP request yourself.
Recommended Free Tools
Troubleshoot common conversion problems
- The URL cannot be converted: PDFCrowd’s servers must be able to reach the URL. Check that it is publicly accessible to the service and not dependent on a local-only host or session. If the content is generated inside your app, pass the rendered HTML as a string or file instead.
- Images or styles are missing: Check that asset URLs are reachable. For relative links, use absolute URLs or a suitable
<base href="…">. For local dependencies, package the HTML and resources together while keeping their relative paths intact. - The wrong page is selected from an archive: When an archive contains multiple HTML documents, configure the documented setting to identify the intended main file.
- Conversion or validation throws an exception: Catch
PdfcrowdError, log the details securely on the server, and return an appropriate error response instead of PDF headers or partial bytes. - The response is not a valid PDF download: Ensure the response uses
Content-Type: application/pdfand that no earlier output has been sent. Emit only the returned PDF bytes after the conversion succeeds. - Saving fails: Check the destination path and PHP process write permissions. If using a bytes-returning method, check whether
file_put_contentsreturnedfalse. - Credentials fail or leak into source control: Confirm the configured username and API key are the account’s credentials, load them from secret configuration, and never include them in a response or public repository.
Performance, reliability, and cost considerations
The official pages cited here do not establish a conversion-time benchmark, reliability percentage, or price figure, so none is quoted. The choice among URL, string, and file input depends on data availability and resource reachability, not on a documented speed ranking. For operational resilience, handle conversion exceptions, avoid returning partial files, and consider how your application should respond when an external conversion request fails.
Best Value
- Convert over 50 document file formats.
- Preview your files from Doxillion before converting them.
- Use batch conversion to convert thousands of files at once.
- Enjoy an easy-to-use, intuitive interface with a Drag and Drop file option.
- Burn your converted or original files directly to disc.
Alternative for screenshot output rather than PDF
If the deliverable can be an image instead of a PDF, ScreenshotNeo is a website screenshot API and MCP server. Its one-call capture is useful when the input is a live website and the required output is PNG, JPEG, or WebP—not a replacement for PDFCrowd’s HTML-to-PDF conversion.
Or skip the browser setup
For a screenshot of a URL, make one request; see the ScreenshotNeo documentation for output and request options.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture. Bot checks, blank pages, and failed loads are never billed; an MCP server lets AI agents take screenshots; and the free plan includes 1,000 screenshots a month with no card, with paid plans starting at $5 for 3,000. Sign up for free.
Further PDFCrowd documentation
For additional PHP and endpoint details, consult the server-side PHP guide and the HTML to PDF API documentation index.
Frequently Asked Questions
Can PDFCrowd convert HTML that only exists inside my PHP application?
Yes. Render the markup in your application and pass it to the string conversion method; include or make reachable any referenced resources.
Does the documented HTTP endpoint prove that version 24.04 is the latest?
No. The cited HTTP guide documents version 24.04, but that alone does not establish that no later version is available.
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.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →




