Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesCall Html2Pdf.app from PHP with a JSON POST to https://api.html2pdf.app/v1/generate, authenticate using the X-API-Key header, and send either raw HTML or a publicly reachable URL in the html field. On synchronous success, the response body is the PDF’s binary data—not JSON. The provider’s PHP guide lists PHP 8.1+ and the PHP cURL extension as requirements. Keep the API key on the server.
Make a synchronous PDF request in PHP
This example converts a public webpage to PDF and saves the returned bytes as document.pdf. Set HTML2PDF_API_KEY in your server environment before running it.
<?php
$apiKey = getenv('HTML2PDF_API_KEY');
if (!$apiKey) {
throw new RuntimeException('HTML2PDF_API_KEY is not set');
}
$payload = ['html' => 'https://www.example.com'];
$ch = curl_init('https://api.html2pdf.app/v1/generate');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-API-Key: ' . $apiKey,
],
]);
$pdf = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$error = curl_error($ch);
curl_close($ch);
if ($pdf === false || $statusCode < 200 || $statusCode >= 300) {
throw new RuntimeException($error ?: 'PDF generation failed; HTTP ' . $statusCode);
}
if (file_put_contents(__DIR__ . '/document.pdf', $pdf) === false) {
throw new RuntimeException('Could not write document.pdf');
}
The provider’s PHP guide and API documentation describe this JSON request pattern. Substitute the value of html with your own URL or HTML string. The URL must be reachable by the conversion service; a page that only loads inside your authenticated browser session will not be available to it.
Convert a string of HTML
For markup you already have in PHP, send the HTML itself rather than a URL:
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
$payload = [
'html' => '<!doctype html><html><body><h1>Invoice</h1><p>Paid</p></body></html>',
'format' => 'A4',
];
Include the document structure, styles, and any content the renderer needs. External images, fonts, stylesheets, and scripts must be reachable by the service for them to appear in the output.
Keep credentials out of client code
Store the key in an environment variable or your framework’s secret store. Do not put it in browser JavaScript, a public repository, or a client-side template. The provider’s PHP guide explicitly says not to call the API directly from browser JavaScript rendered by PHP. Requests should originate from a backend, server-side script, or trusted job.
Return the PDF from a PHP controller
If the request runs inside a web controller, validate the upstream status before sending anything to the visitor. A successful response can be returned with a PDF content type and a download or inline disposition:
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
if ($pdf === false || $statusCode < 200 || $statusCode >= 300) {
http_response_code(502);
exit('PDF generation failed');
}
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="document.pdf"');
echo $pdf;
Use inline instead of attachment if the browser should try to display the PDF. Never pass an error response from the API to the browser as though it were a PDF.
Choose synchronous or asynchronous conversion
| Method | What your PHP request receives | Use it when |
|---|---|---|
| Synchronous | The completed PDF as binary response data. | Your application can keep the request open while conversion runs and needs the file immediately. |
| Asynchronous callback | 202 Accepted when the job is queued; the PDF arrives later in a callback request. |
The work should continue in the background rather than holding a user-facing request open. |
Queue a conversion with a callback
Add callBackUrl to the JSON request to ask for background processing. Use a publicly reachable HTTPS endpoint that accepts POST requests. Include a state value if you need to associate the eventual result with an order, report, or job identifier; the service returns it unchanged.
$payload = [
'html' => 'https://www.example.com',
'callBackUrl' => 'https://your-domain.example/pdf-callback',
'state' => 'report-123',
];
A 202 response means the job was accepted for processing, not that its body contains a PDF. When processing completes, the service POSTs JSON to the callback URL. The callback’s document field contains base64-encoded PDF bytes; decode it before saving or returning the file.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
$callback = json_decode(file_get_contents('php://input'), true);
if (!is_array($callback) || empty($callback['document'])) {
http_response_code(400);
exit('Missing PDF document');
}
$pdf = base64_decode($callback['document'], true);
if ($pdf === false) {
http_response_code(400);
exit('Invalid base64 PDF data');
}
file_put_contents(__DIR__ . '/document.pdf', $pdf);
http_response_code(200);
Make callback handling idempotent: delivery may be attempted more than once, and the documentation says failed delivery is retried up to three times before being marked failed. Record processed job identifiers or otherwise prevent duplicate side effects.
Set rendering options for the document
The API accepts rendering and PDF options in the JSON request alongside html. The documented choices include:
Free tools Windows power users keep installed
One-click scans. No signup required.
format: page format; documented formats include Letter, Legal, Tabloid, Ledger, and A0 through A6.landscape: select landscape orientation.widthandheight: set custom dimensions.marginTop,marginRight,marginBottom, andmarginLeft: configure page margins.media: render usingscreenorprintCSS media.filename: set the document filename.waitFor: wait from 0 to 10 seconds before capture.scale: set rendering scale from 0.1 to 2.- Header and footer templates.
- Password and permission fields for encrypted PDFs.
Use the exact parameter definitions in the API documentation when constructing advanced requests. For example, page format, margins, and media mode can change pagination and styling, so check output with representative pages before relying on it in production.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Troubleshoot failed or unexpected PDFs
| Symptom or status | Likely cause | What to check |
|---|---|---|
400 |
The source URL is inaccessible or a parameter is invalid. | Open the URL without a logged-in browser session; validate option names and values. |
401 |
The API key is absent or invalid. | Confirm the X-API-Key header and server-side secret value. |
403 |
The account reached a plan limit. | Review the account’s plan and notification before retrying. |
500 |
An unhandled server error occurred. | Retry after a short delay; if needed, increase the delay between further attempts. |
| Blank page or missing styles | The page or its resources did not load for the renderer, or the selected CSS media/timing differs from expectations. | Confirm the URL, stylesheets, fonts, and images are publicly reachable; test screen versus print media and allow time for JavaScript-driven content. |
The API documentation warns against automatically retrying 400, 401, or 403 responses before correcting the request, credentials, or account limit. A non-2xx response is not a PDF, even if your PHP code received a response body.
Plan for latency, reliability, and usage cost
Html2Pdf.app says conversion runs in headless Chromium and supports modern HTML, CSS, and JavaScript. Actual output still depends on reachable resources, the selected CSS media mode, and when page scripts finish loading. Test the kinds of pages your application generates, particularly pages that fetch data or render content after load.
Pricing checked on October 3, 2026, on the provider’s official pricing page: Free is $0/month for 100 credits, one parallel conversion, and PDFs up to 1 MB; Startup is $9/month for 1,000 credits and three parallel conversions; Standard is $25/month for 5,000 credits and ten parallel conversions; Scale is $39/month for 10,000 credits and twenty parallel conversions. Paid plans list unlimited PDF size. The provider says each 5 MB chunk of generated PDF costs one credit and credits reset on the first day of each month; verify the current pricing and limits when estimating usage.
Windows 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 reinstallCrashes, 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 minuteBest Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Or skip the browser setup
If your goal is a screenshot rather than a PDF, ScreenshotNeo returns a website screenshot or PDF through one API request. Its cookie/consent handling removes known consent banners, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits cost nothing, with the outcome identified in response headers. It also offers an MCP server for AI agents.
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. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo’s free plan.
Frequently Asked Questions
What PHP version and extension does the Html2Pdf.app PHP guide require?
The provider’s PHP guide lists PHP 8.1 or newer and the PHP cURL extension.
Does Html2Pdf.app return JSON containing the PDF in a synchronous request?
No. On synchronous success, the response body is the PDF’s binary content. The JSON callback flow is separate and sends the document as base64.
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.

