Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
image optimization

How to Speed Up wkhtmltopdf and PDFKit for Long Webpages with Many Images

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The reliable way to make image-heavy PDF generation faster is to measure one representative document, identify whether time is spent fetching images, running JavaScript, rendering, encoding, or starting processes, then change one setting at a time. wkhtmltopdf renders HTML through Qt WebKit; PDFKit is a programmatic PDF generator with a different bottleneck profile. The settings below can reduce unnecessary work, but none is a guaranteed percentage improvement. After every change, compare elapsed time, PDF size, image quality, and visual correctness.

Start with a repeatable baseline

Use the same long page, renderer version, machine, network conditions, and output path for every trial. Warm and cold runs can differ, so record both when startup or caching may matter.

  • Total wall-clock time, including process startup.
  • Output PDF size and page count.
  • Number of images, their pixel dimensions, and whether each is remote or local.
  • Whether JavaScript creates content or loads images.
  • Peak memory and CPU, if your operating system exposes them.
  • Visual checks: missing images, layout shifts, clipped content, incorrect fonts, and altered sharpness.

Run at least several identical conversions before changing anything and keep a table of results. A faster file is not an improvement if dynamic content disappears or print-quality images become unusable.

A minimal timing harness

/usr/bin/time -v wkhtmltopdf --enable-javascript https://example.com/long-page baseline.pdf

For a local HTML file, use an absolute file:// URL or the path format accepted by your platform. If the page requires authentication, reproduce the same headers or cookies in each run.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Epson EcoTank ET-2800 Wireless Color All-in-One Supertank Printer - Black
  • INNOVATIVE CARTRIDGE-FREE PRINTING — No more dealing with lots of tiny ink cartridges; With this wireless document and photo printer each ink bottle set is equivalent to about 90 individual cartridges²
  • LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; When you choose this combination printer, scanner and copier you can print up to 4,500 pages black/7,500 color³
  • COLOR PRINTING — Up to 2 years of ink in the box4 (and with every replacement ink set) for fewer out-of-ink frustrations
  • ZERO CARTRIDGE WASTE — By using an Epson EcoTank printer you can help reduce the amount of cartridge waste ending up in landfills
  • HOME PRINTER DESIGNED FOR RELIABILITY — The Epson EcoTank ET-2800 All-in-One Supertank Color Printer creates vivid, detailed prints and documents thanks to Micro Piezo Heat-Free Technology; Fire off 10 ISO pages per minute1 to easily finish large jobs

Why wkhtmltopdf slows down on image-heavy pages

Qt WebKit must load the document, execute scripts, fetch and decode media, lay out every page, and encode the PDF. A long page multiplies layout and pagination work; many large images increase network, decoding, memory, and output-encoding work. A remote image server, a failed request that waits for a timeout, or a script that never reaches a stable state can dominate the total even when PDF writing itself is quick.

Reduce image work without hiding required content

Resize source files before rendering

Prepare each image near the largest physical size it will occupy in the PDF. Supplying a 6,000-pixel photograph for a 500-pixel slot forces needless download and decode work. Resize with an image pipeline before invoking wkhtmltopdf, retain the original for other uses, and compare fine text and edges in the resulting PDF.

Test image DPI and JPEG quality

The wkhtmltopdf manual documents a default --image-dpi of 600 and a default JPEG --image-quality of 94. These are output controls, not promised speedups. Test a lower DPI and a lower quality that still meets your print requirement:

wkhtmltopdf --image-dpi 300 --image-quality 85 input.html tuned.pdf

Use --lowquality when a smaller, lower-quality PDF is acceptable. Inspect photographs, diagrams, and small labels at their intended viewing size. Do not assume lower quality always makes rendering faster; benchmark your actual document.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Remove images only when they are genuinely optional

--no-images prevents image loading. It can be useful for a text-only export or a diagnostic run that answers “are images the bottleneck?” It is not a safe production optimization when images are part of the document.

Separate network loading from rendering

Make a copy of the page with all required images available locally and compare it with the remote version. A large difference points to DNS, TLS, server latency, rate limits, redirects, or failed requests rather than PDF layout. Also check whether image URLs return an error page, require a cookie, or are blocked by authentication.

wkhtmltopdf exposes image-loading and media-error behavior through command-line and library settings. In a library configuration, the corresponding controls include web.loadImages and load-error handling. Use those settings to create a diagnostic run, then restore strict failure handling for production so missing media is visible instead of silently accepted.

Rank #2
Sale
Epson EcoTank Photo ET-8550 Wireless Wide-Format All-in-One Tank Printer
  • CARTRIDGE-FREE PRINTING — Print lab-quality photos, graphics and creative projects; Get vibrant colors and sharp text with Epson's high-accuracy printhead and Claria ET Premium 6-color inks
  • INK BOTTLES — Save on photos1 and creative projects with affordable in-house printing; All-in-one printer allows you to print 4" x 6" photos for about 4 cents each vs. 40 cents with traditional ink cartridges1
  • LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; Printer, scanner and copier lets you print up to 6,200 color pages³
  • PRINT FOR LONGER — Up to 2 years of ink in the box² (and with every replacement ink set) for fewer out-of-ink frustrations with this wireless printer
  • ZERO CARTRIDGE WASTE — Epson EcoTank printer helps reduce the amount of cartridge waste ending up in landfills; Cartridge-free printer uses high-yield ink bottles; Each replacement ink bottle set is equivalent to about 100 individual ink cartridges⁴

Practical network checks

  • Log each image URL and HTTP status before conversion.
  • Download remote assets once into a temporary directory and render from local paths.
  • Use deterministic asset versions so a cache or changing image cannot invalidate comparisons.
  • Set sensible network timeouts outside the renderer and fail clearly when an asset cannot be retrieved.

Control JavaScript and waiting

JavaScript is enabled by default in the wkhtmltopdf command-line manual, and the documented --javascript-delay default is 200 ms. The library settings expose web.enableJavascript, load.jsdelay, and load.stopSlowScript.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When disabling JavaScript is safe

Try:

wkhtmltopdf --disable-javascript input.html no-js.pdf

Only keep this change if the HTML already contains all text and images needed in the PDF. Client-rendered applications, lazy-loaded images, charts, and authentication flows may produce an incomplete document without scripts.

Shorten an unnecessary delay

If your page is ready immediately, test a smaller delay:

wkhtmltopdf --javascript-delay 50 input.html short-wait.pdf

A delay is not a readiness detector. If scripts still fetch images or build the DOM after 50 ms, the PDF can be missing content. Prefer a page that signals readiness deterministically, and verify that every required selector and image is present before accepting the output.

Handle runaway scripts

Use the slow-script control in library settings when a script can loop or block. Treat a stopped script as a possible correctness failure, not merely a successful speed improvement; record an error and inspect the PDF.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Batch conversions and process startup

If one long page is slow, changing process startup will not materially alter its render time. If you convert many documents, repeated launches can become significant. The manual documents --read-args-from-stdin: each input line is processed as a separate invocation with its arguments combined with the main command.

printf '%sn' 
  'https://example.com/a.pdf a.pdf' 
  'https://example.com/b.pdf b.pdf' 
| wkhtmltopdf --read-args-from-stdin

Adapt quoting for URLs containing spaces or shell metacharacters. Benchmark a batch both with and without this mode. It targets launch overhead, not image decoding or page layout, and it does not make a single conversion intrinsically faster.

Rank #3
HP Smart Tank 5000 Wireless All-in-One Ink Tank Printer, Scanner, Copier with 2 Years of Ink Included, Best-for-Home, Cartridge-Free, Refillable and AI-Enabled. (5D1B6A)
  • SET IT UP ONCE AND PRINT WITH CONFIDENCE. No complicated maintenance. Just easy, reliable printing you can count on.
  • INK FOR YEARS. NOT MONTHS. Up to 2 years of ink included. Get thousands of pages of cartridge-free printing. More pages, less hassle
  • KEEPS PRINTING WELL AFTER COMPETITORS HAVE QUIT. No complex maintenance. Sharper text, richer colors.[2] Only with HP Smart Tank
  • PREMIUM SUPPORT - Strong technical expertise to solve issues faster
  • THE LAST PRINTER YOU'LL EVER NEED. Enjoy years of refillable, cartridge-free printing.

Do not treat smart shrinking as a speed switch

Smart shrinking is enabled by default and changes the pixel-to-DPI relationship used for layout. It is a layout control. Test --disable-smart-shrinking only when scaling, clipping, or pagination is wrong, and compare output dimensions and page breaks. The documentation does not establish a general rendering-speed gain from either setting.

PDFKit requires a different diagnosis

PDFKit creates PDF objects in your application rather than rendering a webpage through a browser engine. Profile the stages separately:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Image reads from disk, object storage, or HTTP.
  2. Image decoding and any resizing or format conversion.
  3. PDFKit drawing and document generation.
  4. Backpressure, filesystem writes, and the destination stream.

Use a monotonic timer around each stage and capture memory usage. A slow HTTP request should be fixed at the fetch layer; a huge decoded bitmap should be resized before insertion; a blocked output stream requires stream handling rather than renderer flags.

Understand PDFKit page buffering

PDFKit normally flushes pages to the output as new pages are created. Setting bufferPages: true lets code revisit earlier pages and is documented for versions 0.7.0 and later. It is intended for tasks such as adding page numbers, not as a measured speed optimization. Buffering can increase memory pressure on long documents.

const PDFDocument = require('pdfkit');
const fs = require('node:fs');

const doc = new PDFDocument({ bufferPages: true });
doc.pipe(fs.createWriteStream('report.pdf'));
// Add pages and images here.
const range = doc.bufferedPageRange();
for (let i = range.start; i < range.start + range.count; i++) {
  doc.switchToPage(i);
  doc.fontSize(9).text(`Page ${i + 1}`, 50, 760);
}
doc.end();

For maximum throughput, avoid buffering unless you need to edit earlier pages. Stream output and monitor the destination’s drain behavior instead of accumulating the entire PDF in memory.

A safe optimization workflow

  1. Capture a baseline and save the PDF.
  2. Classify the bottleneck: network, JavaScript/readiness, image decode, layout, encoding, startup, or output I/O.
  3. Change one variable: resized assets, local assets, DPI, quality, JavaScript, delay, or batch mode.
  4. Run the same timing protocol.
  5. Check every page for missing or shifted content and compare file size and image quality.
  6. Keep the change only when its trade-off fits your requirements; otherwise revert it.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common failures

Images are missing

Check URL status, redirects, TLS, authentication, relative paths, and file permissions. Render with local copies to isolate network access. If disabling JavaScript caused the failure, restore scripts or make image loading server-side.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The PDF finishes quickly but is incomplete

The delay may be too short, JavaScript may be disabled, or a slow script may have been stopped. Increase the wait temporarily, add a deterministic readiness condition in the page, and compare the DOM content that exists at capture time.

Rank #4
NDYIN Portable Printers Wireless for Travel, N80 Bluetooth Thermal Printer
  • Wireless Bluetooth Printer: Portable thermal printer compatible with iPhone, Android phones, iPad and tablet computers via Bluetooth. For smartphones, please download the "Nada Print" App. You can also connect to laptops and computers for printing using a USB-C cable. (Note: Laptops and computers can only be connected via USB and require the installation of a driver first. Bluetooth connection is not supported.)
  • No-ink printing: Only supports US Letter and A4 size thermal paper.(Doesn't support regular paper) The no-ink portable thermal printer uses direct thermal technology, requiring no ink, toner or ribbons, making it environmentally friendly, cost-effective and time-saving. The thermal printer package comes with a roll of US Letter thermal printing paper. Note: When installing the paper, remember to switch the paper size switch on APP
  • Clear Print: NDYIN N80 portable thermal printer adopts high-definition printing technology, with a 203DPI resolution to provide you with clear printing results. This mobile printer is compatible with roll paper, folded paper and tattoo transfer paper, supporting printing from your mobile phone PDF, Word, pictures and web pages anytime and anywhere. It is recommended to use our NDYIN thermal paper to achieve good printing quality
  • Portable wireless printer for travel: The thermal printer is equipped with a built-in 1500mAh rechargeable battery, which can print 160 sheets of 8.5" x 11" thermal paper after being fully charged. It weighs only 1.5 pounds and is compact in size. This ink-free portable printer can be easily carried in a backpack or briefcase! It is perfect for business travel, cars, small offices, construction sites, schools and homes. You can print documents, contracts, invoices and boarding passes anytime and anywhere
  • The N80 thermal printer has a wide range of uses. The package includes the N80 printer, a roll of US Letter paper(7m/roll), a user manual, a guide card, a type-C soft cable and a type C adapter. Note: The charging adapter is not included. Special thermal paper is required for use; ordinary paper cannot be used. This ink-free portable thermal printer is suitable for various scenarios such as home, school, travel, office, and outdoor, meeting the printing needs of different groups of people. This tattoo template printer is also compatible with tattoo transfer paper, making it an ideal choice for tattoo art

Conversion hangs or times out

Look for an unreachable asset, an endless script, a stalled response, or a page waiting on an external service. Test a local asset set, enforce request timeouts, and use slow-script handling. Do not merely increase the timeout without finding the blocker.

Output is smaller but unreadable

Restore DPI or JPEG quality incrementally. Resize images to their actual print dimensions rather than compressing everything aggressively.

Batch mode produces incorrect filenames

Each stdin line is parsed as arguments. Quote paths and URLs correctly, test a two-document batch, and use explicit output names with characters safe for your shell.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

User content creates a security risk

The wkhtmltopdf project warns not to use it with untrusted HTML unless user-supplied HTML and JavaScript are sanitized; otherwise the renderer can expose the server to a complete takeover. Sandbox conversion, restrict network access, validate URLs, and treat this security work as separate from performance tuning.

Or skip the browser setup

If your goal is a clean screenshot or PDF rather than reproducing a local wkhtmltopdf pipeline, ScreenshotNeo provides a single request to its website screenshot API. It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers identify the page verdict and billing status.

cURL:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python:

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)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

See the complete parameter reference in the ScreenshotNeo documentation. Options include full-page capture with lazy images loaded, CSS-selector element capture, device and viewport control, retina scale, PDF paper and margin settings, custom CSS and JavaScript, waits, request blocking, headers, cookies, timezone, geolocation, resizing, chosen cache TTL, signed image links, asynchronous webhooks, bulk capture of up to 100 URLs per call, usage data, and an MCP server with take_screenshot, get_page_info, and capture_pdf for AI agents.

The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 screenshots, and every feature is available on every plan. Create a free ScreenshotNeo account.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Can I make one very long wkhtmltopdf page fast just by adding more CPU?

More CPU may help only when profiling shows CPU saturation. It will not fix slow remote requests, blocked JavaScript, oversized images, or a stalled output stream.

Should I convert every image to JPEG?

No. Choose a format appropriate to the artwork and test readability. JPEG quality controls apply to JPEG compression; converting line art or transparency-heavy images can reduce fidelity.

Is PDFKit a drop-in replacement for wkhtmltopdf?

No. wkhtmltopdf renders HTML/CSS through Qt WebKit, while PDFKit requires you to construct PDF content in code. Migrating usually means rebuilding layout and pagination logic.

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.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.