Recommended Free Tools
To call wkhtmltopdf from Node.js, install the wkhtmltopdf command-line program separately, then launch it asynchronously with Node’s node:child_process API. The npm package named wkhtmltopdf is a wrapper; it does not include the executable. For most server code, execFile with an argument array is a straightforward starting point because it does not invoke a shell by default.
Install and verify the executable
- Install a
wkhtmltopdfbinary for the operating system and architecture used by your application. The project download page lists the 0.12.6 stable series, released June 11, 2020; its download matrix describes that release and is not a guarantee of compatibility with every current environment. See the official downloads page. - Verify the executable is available to the same user and environment that runs Node:
wkhtmltopdf --version. If that command is not found, add the binary’s directory to the processPATHor use its explicit path in your Node code. - If using the npm wrapper, install it separately with
npm install wkhtmltopdf. Its README documents the wrapper API, but the executable still needs to be installed independently: npm package README. - Test in the target production image, including fonts, permissions, network access and any local CSS, image or font paths your page requires.
The reviewed npm package page identifies wrapper version 0.4.0 and does not establish a current compatibility promise for modern Node.js releases. Confirm the wrapper and binary against your actual runtime before relying on them.
Call wkhtmltopdf directly with execFile
For a URL-to-PDF conversion, pass the executable and each option as a separate argument. The following example writes to a temporary file and reports failures without blocking Node’s event loop:
import { execFile } from 'node:child_process';
const inputUrl = 'https://example.test/report';
const outputPath = '/tmp/report.pdf';
execFile(
'wkhtmltopdf',
['--quiet', inputUrl, outputPath],
{ timeout: 30_000 },
(error, stdout, stderr) => {
if (error) {
console.error('wkhtmltopdf failed', {
message: error.message,
code: error.code,
signal: error.signal,
stderr: stderr.toString(),
});
return;
}
console.log(`PDF written to ${outputPath}`);
},
);
Save this as an ES module (for example, convert.mjs) and run it with Node. Replace the URL and output location with values appropriate to your service; make sure the output directory exists and is writable. Node’s execFile accepts a command, argument array and options, and launches without a shell unless you explicitly request one. See Node.js child process documentation.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →#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.
In an HTTP service, do not send a success response until the child has completed successfully and the output is ready. Treat nonzero exit status as failure; a file can exist even when conversion did not finish correctly. Set a timeout and cancellation policy suited to your workload, and remove temporary files after delivery or on failure.
Use an explicit binary path when PATH is unreliable
When the executable is installed outside the service’s normal search path, pass its absolute path as the first argument instead of 'wkhtmltopdf', for example '/usr/local/bin/wkhtmltopdf' where that is the actual installed location. Do not assume this example path exists on your host.
Convert HTML you have written to a file
You can write trusted, application-generated HTML to a temporary file and pass that file as the input argument. For local pages, assets such as stylesheets and fonts may require local-file access; the command’s documentation says access is disabled by default for a local input page reading other local files. Use --allow only for the specific directories the conversion needs, and check behavior with the exact binary in deployment. See the command usage documentation.
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.
Use the npm wrapper when its stream API fits
The wrapper can accept a URL or HTML input and pipe generated output to a writable stream. Its README also documents options and an optional callback. Set its documented command property to an explicit executable path if PATH lookup is unsuitable. The package is a convenience layer around the separately installed program, not a replacement for installing it. Consult the package README for the API shape and verify it against your installed versions.
Handle output, timeouts and streaming deliberately
For small conversions, writing to a temporary file and serving that file after successful completion is operationally simple. For larger output or a response that needs to stream, use an asynchronous, stream-oriented child-process design such as spawn. Connect the child’s output to a writable destination and handle both process errors and completion status. If the process exits unsuccessfully, stop or invalidate the downstream response rather than treating partial PDF bytes as a valid document.
Node’s synchronous child-process methods block the event loop while the process runs; use asynchronous APIs in a server so other requests can continue to be handled. Set limits on conversion time and concurrent processes, and clean up child processes and temporary files on request cancellation or timeout. The appropriate limits depend on the workload; the source materials establish no universal performance figure.
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.
Security: do not process untrusted HTML
The wkhtmltopdf project warns: “Do not use wkhtmltopdf with any untrusted HTML – be sure to sanitize any user-supplied HTML/JS, otherwise it can lead to complete takeover of the server it is running on!” Sanitization alone should not be treated as a complete sandbox. Prefer controlled templates and data, run the converter with minimal privileges, and restrict its filesystem and network access using environment-appropriate controls. The project status page also recommends considering mandatory access controls such as AppArmor or SELinux: wkhtmltopdf status.
Do not concatenate user input into a shell command. Keep the executable fixed and pass inputs as arguments to execFile or spawn; Node warns that shell execution with unsanitized input can enable arbitrary command execution. If you provide an environment object to the child process, preserve the needed PATH when command lookup depends on it.
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 problemsChoose rendering options based on the page
The command documentation says JavaScript is enabled by default and lists a default JavaScript delay of 200 ms. A fixed delay does not prove that a dynamic application has finished rendering. You can adjust the delay or disable JavaScript with the documented flags, but verify the output rather than assuming a wait is sufficient.
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
- Dynamic content: confirm required data is present in the output. The project suggests considering Puppeteer for sites that rely on dynamic JavaScript.
- Missing local assets: check local-file access settings and grant only the paths needed with
--allow. - Missing remote assets: check that the converter can reach the page’s CSS, images and fonts, and review load-error behavior.
- Layout differences: check fonts, print versus screen media styles, paper size, margins, and the converter build used in production.
- Large or slow pages: tune timeouts and process concurrency to the application, and ensure a timed-out request does not leave a converter running.
The usage manual documents load-error modes (abort, ignore or skip), media-load error handling, image disabling, print/screen media settings and local-file access controls. These are behavior controls, not guarantees of compatibility with contemporary browser features.
Troubleshoot common Node.js and conversion failures
| Symptom | Likely cause | What to check |
|---|---|---|
ENOENT or “command not found” |
The executable is not installed, or the Node process cannot find it on PATH. | Run wkhtmltopdf --version as the service user; set the correct PATH or use the binary’s actual absolute path. |
| Permission error | The process user cannot execute the binary or write the destination. | Check executable permissions and output-directory ownership; avoid running the service with unnecessary privileges. |
| Nonzero exit or missing/invalid PDF | Conversion failed, a resource could not load, or the page was incomplete. | Log the exit error and stderr safely; test the URL and assets from the production environment and inspect the selected load-error options. |
| Local CSS, images or fonts are absent | Local-file access is restricted, or the relevant paths were not permitted. | Use a controlled asset directory and narrowly grant it with --allow; verify with the exact binary. |
| Page content is blank or stale | JavaScript-dependent content did not finish before capture, or the delay is inadequate. | Check whether the content requires JavaScript, test an appropriate delay, and consider a renderer intended for dynamic pages. |
| Conversion hangs or is killed | A slow page, unreachable resource or runaway conversion exceeded operational limits. | Set a timeout, handle cancellation, and prevent abandoned child processes from continuing. |
| Behavior differs between development and production | Different binary builds, fonts, architecture, permissions or resource access. | Compare the actual binary version and environment, then test using the production image and service account. |
Check whether wkhtmltopdf fits the project
The project’s download page lists 0.12.6 as its stable series, released June 11, 2020. Its status page notes that Qt 4 has been unsupported since 2015 and that its WebKit version had not been updated since 2012. Treat compatibility and maintenance as deployment questions to verify, rather than assuming a planned project direction has shipped.
The project recommends considering WeasyPrint or commercial Prince for reports generated from HTML under your control, and Puppeteer for sites using dynamic JavaScript. Those are project recommendations, not comparative benchmarks. Evaluate output fidelity for your templates, JavaScript completion, security maintenance, dependencies and fonts, current platform support, and licensing or commercial terms before switching: project status and alternatives.
Best 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 you need a screenshot rather than a PDF, ScreenshotNeo is a website screenshot API and MCP server for developers. One GET request can return PNG, JPEG, WebP or a PDF. For example, using cURL:
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 options and response details. It accepts cookie/consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups and chat widgets before capture; each cleanup step can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and the response identifies the page verdict and billing status in headers. Its MCP server gives AI agents tools for screenshots, page information and PDF capture. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000.
Sign up free for ScreenshotNeo to try 1,000 screenshots a month without a credit card.
Frequently Asked Questions
Does the npm wkhtmltopdf package include wkhtmltopdf?
No. It is a Node.js wrapper; install the command-line executable separately.
Can wkhtmltopdf render JavaScript?
It has JavaScript enabled by default, but its documented default delay is 200 ms and that does not guarantee a dynamic page has finished rendering.
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.

