DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober 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
CPU optimization

How to Reduce High CPU Usage When Generating PDFs with Wicked PDF in Rails

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

Start by measuring the right process. Wicked PDF runs the external wkhtmltopdf executable, so a slow or CPU-heavy PDF request can involve both Rails and a separate converter process. Record Rails request time and CPU, then measure the wkhtmltopdf child process before changing options. The practical fixes are to remove rendering work that the document does not need and to limit how many conversions can run at once.

1. Find out where the CPU is going

Wicked PDF is a Rails wrapper; it does not render the PDF inside the Ruby process. It starts wkhtmltopdf and waits for that process to finish. A Rails application metric alone can therefore under-report the converter’s CPU use.

Measure both sides of the boundary

  1. Capture the Rails request duration, status, allocated memory and application CPU.
  2. Observe the child wkhtmltopdf process during the same request. On Linux, process tools such as ps, top or your container/orchestrator metrics can identify its CPU and resident memory.
  3. Record document characteristics: page count, HTML size, image count and pixel dimensions, JavaScript use, external resources, output bytes and the number of simultaneous conversions.
  4. Repeat with representative documents at the concurrency your production system actually reaches. A tiny invoice can hide the cost of a long report with large images.

Use conversion wall time, converter CPU time, peak memory, output size, queue wait and visual correctness as your comparison set. The project material does not publish a controlled benchmark or a universal percentage reduction, so treat each change as an experiment in your own deployment.

2. Disable JavaScript when the PDF does not need it

The documented wkhtmltopdf command-line interface enables JavaScript by default and documents a JavaScript delay whose default is 200 milliseconds. Scripts that animate, fetch data, build charts or keep the page busy can add work even when the final PDF needs none of it.

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

Test a no-script render

With Wicked PDF, pass the converter option for the particular document:

render pdf: "report", wkhtmltopdf: { disable_javascript: true }

If your installed Wicked PDF version expects an option string or array, use the equivalent --disable-javascript argument supported by your binary. Confirm the exact generated command in your application logs.

Remove an explicit JavaScript delay when it is no longer needed, rather than merely shortening it. Keep scripts and an appropriate delay when they populate required content; disabling them can produce missing totals, empty charts or an incomplete table. Compare the resulting PDF, not just CPU graphs.

3. Simplify the HTML and asset workload

Every image decoded, stylesheet applied and script executed increases the converter’s work. Start with the HTML that is actually required for a PDF rather than sending the full interactive page.

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

Remove unnecessary content

  • Render a PDF-specific view without navigation, carousels, chat launchers, analytics and hidden application panels.
  • Delete unused JavaScript and CSS from that view.
  • Reduce oversized source images to dimensions appropriate for their printed size. Keep text and diagrams at a resolution that remains legible.
  • Only include fonts and images used by the document.

Evaluate image options carefully

wkhtmltopdf exposes image-loading controls and global image DPI and quality settings. Lowering quality or DPI may reduce output bytes and sometimes work, but it can make small text, screenshots or fine lines unreadable. Make one change, then compare CPU time, elapsed time, PDF size and printed appearance. No supplied source establishes a setting that always lowers CPU.

Use valid, reachable asset URLs

The converter runs outside Rails. Use Wicked PDF’s documented helper-based references (for example, its asset helpers) or otherwise provide URLs the child process can resolve. An unavailable stylesheet, image or font can interfere with other images in the PDF and can make troubleshooting look like a CPU problem. During diagnosis, enable useful converter logging and fix 404s, TLS failures and blocked requests before tuning performance.

4. Move work out of synchronous requests

If a user does not need the PDF in the same HTTP response, enqueue generation in a background job. A request can create a job, return a status page or notification, and let a bounded worker pool run the converter.

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⁴

Example Active Job flow

class PdfReportJob < ApplicationJob
  queue_as :pdf

  def perform(report_id)
    report = Report.find(report_id)
    html = ApplicationController.render(
      template: "reports/report",
      assigns: { report: report }
    )

    pdf = WickedPdf.new.pdf_from_string(
      html,
      javascript_delay: 0,
      disable_javascript: true
    )

    ReportPdfStore.write!(report, pdf)
  end
end

# Controller
PdfReportJob.perform_later(@report.id)
render json: { status: "queued" }, status: :accepted

Use the option names supported by your Wicked PDF release; the example assumes the report is valid without client-side scripts. Configure the queue system with a deliberate maximum number of PDF workers instead of allowing every web request or job thread to start a converter.

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

Understand what queueing changes

The Wicked PDF project wiki describes a qualitative reduction in production CPU activity after background generation prevented multiple converter instances from running simultaneously. It does not provide controlled measurements. Queueing limits overlap and smooths peaks; it does not prove lower total CPU for the same number of documents. The trade-off is possible queue wait and higher end-to-end latency.

5. Control concurrency and resource pressure

Each conversion is a separate process. If eight workers render large reports together, CPU and memory can spike even when one report is acceptable. Set a queue concurrency limit based on observed CPU, memory and acceptable wait time, then load-test with representative files.

  • Keep PDF jobs on a queue separate from latency-sensitive web work.
  • Cap the number of workers that consume that queue.
  • Set job timeouts and retries that do not create a storm of duplicate conversions.
  • Monitor process count, peak resident memory, CPU throttling and disk usage for temporary files.
  • Use backpressure or rate limits when users can request many reports at once.

A lower worker count may increase queue wait while protecting the host. Choose the point that meets your service-level target rather than assuming maximum parallelism is fastest.

6. Verify the converter and its deployment

The wkhtmltopdf downloads page identifies the 0.12.6 series as the stable project release, dated June 11, 2020. That date describes the page’s stated release information; it is not a guarantee of current maintenance or suitability for your operating system. Record the actual binary build, operating-system package, architecture, Qt variant and Wicked PDF gem version in your deployment notes.

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

Run the same binary in the production-like container or host where the job executes. Differences in fonts, SSL libraries, available shared memory, sandboxing and CPU limits can change both output and resource use. Do not compare a laptop binary with a restricted production container and call the difference an optimization.

7. Treat HTML and network access as a security boundary

The upstream 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!” Wicked PDF likewise advises sanitizing user-generated HTML, CSS and JavaScript or at least disallowing requests to internal IP addresses and hostnames.

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.
  • Sanitize user-supplied markup and scripts before rendering.
  • Restrict local-file access and network fetching to assets the document requires.
  • Block requests to internal addresses, metadata services and private hostnames.
  • Use an isolated worker with least-privilege credentials and a controlled temporary directory.
  • Log blocked and failed resource requests without exposing sensitive HTML.

Security controls can also prevent hangs caused by unreachable resources, but their primary purpose is protecting the host, not promising a CPU reduction.

8. A repeatable tuning procedure

  1. Baseline: choose several real documents and record Rails time, converter CPU time, peak memory, output bytes, page count and correctness at one and several concurrent jobs.
  2. Remove scripts: render with JavaScript disabled and no unnecessary delay; reject the change if content is missing.
  3. Simplify assets: remove unused elements, resize oversized images and fix failed URLs.
  4. Test image settings: compare DPI and quality variants for legibility, size and resource use.
  5. Limit overlap: move work to a queue and test bounded worker counts.
  6. Recheck under load: include queue wait, retries and host-level throttling, not just a single-document run.

Keep the change that meets your latency, throughput, fidelity and peak-resource requirements. There is no documented universal winner between simplifying each render and reducing concurrency; they address different parts of the problem.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

9. Troubleshooting common symptoms

Rails is fast but the request still times out

Inspect the child process and resource logs. Large images, JavaScript delays, unreachable URLs or a saturated CPU can keep wkhtmltopdf running after Rails has finished preparing the view. Fix the failing resource, simplify the document or move generation to a queue.

The PDF is blank after disabling JavaScript

The page likely builds required content in the browser. Restore JavaScript for that view, or render the data server-side so the PDF HTML is complete before conversion.

Images disappear or one missing image affects others

Check the converter’s ability to resolve every asset from its execution environment. Use Wicked PDF asset helpers or valid absolute references, verify authentication and TLS, and inspect logs for failed requests.

CPU spikes only during traffic bursts

Count concurrent converter processes and cap the PDF queue’s workers. A background job alone does not limit concurrency if the worker pool is unbounded.

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

Lower quality made the file smaller but unreadable

Restore the last legible DPI or quality value and optimize source images individually. File size is not a sufficient success metric.

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

Jobs hang or retry repeatedly

Set a realistic timeout, identify the URL or script that never completes, and restrict external requests. Ensure retries do not launch duplicate work while the original converter is still alive.

Or skip the browser setup

If your task is obtaining a clean image or PDF of a web page rather than rendering a Rails view, ScreenshotNeo provides a single HTTP request. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups and chat widgets; each step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.

See the parameter reference in the ScreenshotNeo documentation. The following calls use the supplied API shape; replace the URL with the page you need.

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.

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}`);

ScreenshotNeo includes full-page capture with lazy-image loading, CSS-selector element capture, device and viewport controls, retina scale, PDF paper and margin options, custom CSS/JavaScript, click and wait actions, request blocking, headers, cookies, authorization, timezone and geolocation, transparent backgrounds, resizing, chosen-TTL caching, signed links, asynchronous webhooks, bulk capture of up to 100 URLs per call, usage reporting and an OpenAPI specification. Its parameter names are compatible with those used by other screenshot APIs, which can simplify migration.

Plans include 1,000 screenshots per month free with no card; paid plans start at $5 for 3,000 shots. Yearly billing provides two months free, and every feature is included on every plan. Create a free ScreenshotNeo account.

10. What a good production configuration looks like

A robust setup measures Rails and converter processes separately, generates a PDF-specific HTML view, disables JavaScript only where the output is server-complete, uses reachable and restricted assets, and runs conversions in a bounded queue. It also records the binary and gem versions, enforces timeouts and network policy, and validates output after every performance change. This combination controls peak load without claiming that any one flag will reduce CPU for every document.

Frequently Asked Questions

Does Wicked PDF itself render HTML?

No. Wicked PDF starts the external wkhtmltopdf executable, so both the Rails process and that child process must be measured.

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

Will a background queue reduce total CPU?

Not necessarily. Queueing limits simultaneous converter processes and smooths peaks; total work for the same documents may remain similar.

Is wkhtmltopdf 0.12.6 a current release?

The project downloads page identifies 0.12.6 as its stable series released June 11, 2020. Check your binary, operating system and maintenance requirements before deployment.

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.

Leave a Reply

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

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.

Read next

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

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.