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

Use a package that matches the Colab runtime, install it with apt, then run wkhtmltopdf input.html output.pdf. Start by checking the runtime’s Ubuntu release and CPU architecture. The commonly documented Focal amd64 package works only when those values match; Colab images can change, so treat the download URL as an example rather than a permanent guarantee.

What wkhtmltopdf does in Colab

wkhtmltopdf is an open-source command-line renderer that converts HTML or a web URL into PDF with the Qt WebKit engine. Its documentation says it runs headlessly and does not normally need a desktop display or display service. The basic form is:

wkhtmltopdf input.html output.pdf

Google Colab gives you a temporary Linux runtime, not a preconfigured desktop. You therefore install the executable inside the current runtime, create or upload HTML, convert it, and download the resulting PDF. Packages and files disappear when the runtime is reset or disconnected.

1. Inspect the Colab runtime before downloading anything

Open a new code cell and run:

!cat /etc/os-release
!uname -m

Record the distribution release and architecture. The example package below is for Ubuntu/Debian-style systems using the Focal (Ubuntu 20.04) amd64 build. An x86_64 result corresponds to amd64. Do not install that file on an incompatible architecture or a runtime whose libraries do not match.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Dell Optiplex 7050 SFF Desktop PC Intel i7-7700 4-Cores 3.60GHz 32GB DDR4 1TB SSD WiFi BT HDMI Duel Monitor Support Windows 11 Pro Excellent Condition(Renewed)
  • Model: Dell OptiPlex 7050 Small Form Factor (SFF)
  • Processor: Intel Core i7-7700 3.60 GHz
  • Memory: 32GB DDR4 Ram
  • Storage: 1TB Solid State Drive (SSD) Fast Boot + Storage
  • Operating System: Windows 11 Pro (64-bit)

The project’s downloads page identifies the 0.12.6 series as stable, released June 11, 2020, with release assets hosted on GitHub. Because that release is old relative to changing Colab images, re-check the live release assets and runtime metadata if installation fails.

2. Install wkhtmltopdf correctly

For a compatible Focal amd64 runtime, this sequence downloads the Debian package, refreshes package metadata, installs the package and verifies the command:

!wget -O wkhtmltox.deb https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb
!sudo apt-get update
!sudo apt-get install -y ./wkhtmltox.deb
!wkhtmltopdf --version

Use apt-get install ./wkhtmltox.deb, not a manual copy of the .deb into /usr/bin. Apt reads package metadata and resolves dependencies. Copying the archive as if it were an executable is a known cause of permission and “Exec format error” failures.

A successful verification prints a version string. If the install reports unresolved dependencies, stop and inspect /etc/os-release, the architecture, and the current project release assets instead of repeatedly retrying the same URL.

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.

3. Create an HTML document in the notebook

This Python cell writes a UTF-8 HTML file into the runtime’s working directory:

from pathlib import Path

html = """


  
  Colab PDF test
  


  

Hello from Colab

This page was converted by wkhtmltopdf.

""" Path("input.html").write_text(html, encoding="utf-8")

Convert it and download the result:

!wkhtmltopdf input.html output.pdf

from google.colab import files
files.download("output.pdf")

For a public page, pass its URL instead of a local filename:

!wkhtmltopdf https://example.com output.pdf

The URL must be reachable from the Colab runtime. A site that requires a login, blocks automated traffic, or renders its content only after unsupported browser interaction may produce an incomplete document.

Rank #2
Apple 2026 MacBook Neo 13-inch Laptop with A18 Pro chip: Built for AI and Apple Intelligence, Liquid Retina Display, 8GB Unified Memory, 256GB SSD Storage, 1080p FaceTime HD Camera; Blush
  • AN AMAZING MAC AT A SURPRISING PRICE — With an incredibly portable and durable aluminum design, up to 16 hours of battery life,* and the A18 Pro chip, MacBook Neo is ready to go wherever school takes you.
  • FOUR STUNNING COLORS. ONE DURABLE DESIGN — Choose from four beautiful colors — Silver, Blush, Citrus, or Indigo — each with a color-coordinated keyboard. And MacBook Neo is made with a durable recycled aluminum enclosure that helps it reach 60 percent recycled content by weight — the most ever in any Apple product.*
  • FLY THROUGH EVERYDAY ASSIGNMENTS — Whether you’re cramming for finals, using Apple Intelligence* to summarize class notes, creating presentations, or even playing the latest Apple Arcade game,* MacBook Neo delivers the performance and AI capabilities you need to get things done.
  • UP TO 16 HOURS OF BATTERY LIFE — MacBook Neo delivers all day battery life, so you can power through from early morning classes to late night study sessions without worrying about plugging in.
  • A VIBRANT 13-INCH DISPLAY* — The gorgeous Liquid Retina display on MacBook Neo supports 1 billion colors, so photos and videos pop and text is crisp for easy reading.

4. Useful rendering options

Put global options before the input and output arguments. The command reference documents options for page dimensions, JavaScript, print styles, local files, headers and footers.

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

Control paper and orientation

!wkhtmltopdf --page-size A4 --orientation Landscape input.html landscape.pdf

Choose the paper size and orientation that match the document rather than relying on defaults. Margins, header text, footer text and page numbering can also be set with the corresponding command-line options documented by the project.

Wait for JavaScript

!wkhtmltopdf --javascript-delay 3000 https://example.com dynamic.pdf

The delay is in milliseconds. It gives scripts time to populate a page, but it does not make modern browser APIs universally compatible with Qt WebKit. Confirm the page is reachable and inspect the generated PDF before increasing the delay.

Use print styles

!wkhtmltopdf --print-media-type input.html print-media.pdf

This asks the renderer to apply print-oriented CSS. Keep print rules deliberate: navigation, animations and screen-only controls may otherwise appear in the PDF.

Allow local assets only when necessary

!wkhtmltopdf --enable-local-file-access input.html local-assets.pdf

Use this only when the HTML references local CSS, images or fonts. Keep those files in a controlled directory. Enabling local access broadens what page content can read from the runtime filesystem.

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.

Pass request headers when a server needs them

The command reference includes header options for requests. Use them for a legitimate, temporary access requirement, and never place API keys or session cookies in a notebook that will be shared.

5. Local files, images and fonts

Relative paths are resolved from the HTML file’s location. A predictable layout helps:

Rank #3
Sale
HP Essential 2026 Laptop Student Business, Ultra Light, 4GB RAM, Intel CPU
  • Performance: Powered by Intel Celeron N4500 dual-core processor with up to 2.8 GHz burst frequency and 4MB L3 cache, this HP Chromebook delivers smooth multitasking for everyday computing. With 4GB LPDDR4x-2933 RAM and Intel UHD Graphics, enjoy seamless web browsing, video streaming, and productivity apps. Chrome OS boots in seconds and updates automatically, keeping your laptop secure and running at peak performance for students, professionals, and home users.
  • Immersive 14-Inch HD Display: Experience clear, vibrant visuals on the 14-inch diagonal HD (1366 x 768) anti-glare display with 250 nits brightness and 62.5% sRGB color accuracy. The micro-edge design maximizes your viewing area with an impressive 80% screen-to-body ratio, perfect for streaming movies, video calls, and document editing. The anti-glare coating reduces eye strain during extended use, making it ideal for all-day productivity and entertainment in any lighting condition.
  • Advanced Connectivity & Ports: Stay connected with Wi-Fi 6 (2x2) for faster wireless speeds and Bluetooth 5.3 for seamless device pairing. Equipped with versatile ports including 1 USB Type-C 10Gbps (with USB Power Delivery and DisplayPort 1.4), 2 USB Type-A 5Gbps ports, 1 HDMI 1.4b, and 1 headphone/microphone combo jack. Connect external monitors, transfer files quickly, charge your device, and expand your workspace effortlessly for maximum productivity and flexibility.
  • All-Day Battery & Premium Design: The battery keeps you powered throughout your day, while the included 45W USB Type-C power adapter ensures fast charging. Featuring a sleek modern grey finish with vertical brushing pattern on the keyboard deck, this lightweight 3.35 lb Chromebook combines style and portability. The full-size modern grey keyboard and HP Imagepad provide comfortable typing and precise navigation for work, school, or entertainment on the go.
  • Enhanced Security & Multimedia: Built-in H1 secure microcontroller protects your data and privacy with enterprise-grade security. The HP True Vision 720p HD camera with integrated dual array digital microphones delivers crystal-clear video calls and online meetings. HD Audio with stereo speakers provides rich, immersive sound for music, videos, and calls. With 64GB eMMC storage, you have ample space for essential files while Chrome OS seamlessly integrates with Google Drive for cloud storage.
from pathlib import Path
Path("assets").mkdir(exist_ok=True)
# Write input.html and place images, CSS and fonts below assets/

If an image is missing, check its path, file permissions and format. For local resources, use --enable-local-file-access only for the directory you control. Remote resources must be accessible to the runtime and may fail because of TLS, authentication, robots rules or network restrictions.

6. Direct invocation or a Python wrapper?

Approach Best fit Trade-off
Shell command Occasional conversions, notebooks and batch jobs Smallest dependency chain; direct access to every CLI flag and clear process exit status
Python wrapper Application code that benefits from a Python API Convenient object-level calls, but wrapper documentation lists additional Linux components such as Xvfb and font packages

A wrapper still needs the wkhtmltopdf executable. If your notebook only converts a few files, subprocess or a shell cell avoids adding another package layer. For a wrapper, follow that project’s installation instructions and verify its required system packages in the current Colab image.

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

7. Troubleshooting common Colab failures

“Exec format error”

Cause: the binary architecture does not match the runtime, or the Debian archive was treated as an executable. Fix: rerun !uname -m, select a matching release asset, and install the archive with sudo apt-get install -y ./wkhtmltox.deb.

Permission denied or command not found

Cause: installation did not complete or the executable is not on PATH. Fix: run !wkhtmltopdf --version, review the apt output, and reinstall the package rather than copying files manually.

Unmet dependencies

Cause: the package targets a different Ubuntu/Debian release, or the Colab image has moved on. Fix: inspect /etc/os-release, run !sudo apt-get update, and consult the current GitHub release assets. Do not assume the 2020 Focal package remains compatible forever.

Blank, partial or stale dynamic pages

Cause: JavaScript has not finished, the site needs browser features Qt WebKit does not provide, or the URL is blocked. Fix: test reachability, add a measured --javascript-delay, use print CSS where appropriate, and inspect the PDF. A delay cannot fix an unsupported application or an authentication wall.

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

Missing CSS, images or fonts

Cause: incorrect relative paths, inaccessible remote resources or local-file restrictions. Fix: keep assets beside the HTML, check paths and permissions, and add --enable-local-file-access only for controlled local content.

Rank #4
Dell Optiplex 3060 Desktop Computer | Intel i5-8500 (3.2) | 32GB DDR4 RAM | 1TB SSD Solid State | Built in WiFi | Bluetooth | Windows 11 Professional | Home or Office PC (Renewed)
  • [INTEL POWERED CONTENT] - Built with a 8th Generation Hexa-Core Intel i5 and 32GB of DDR4 RAM; Modern, Windows 11 ready, with 4K support, Executive multitasking, media streaming and smooth, multi-tab web browsing; Perfect as an all-purpose multimedia computer; built for content creators; Plenty of RAM and Mass storage for photo and video editing powered by Intel HD 630
  • [LATEST WIRELESS TECH] - This Dell Desktop Computer easily connects to the internet through the Built In WiFi / Bluetooth
  • [SOLID STATE STORAGE] - This Dell Computer setup comes with an ultra-fast 1TB Solid State Drive (SSD); Setup as the primary boot device; Boot and load programs with lightning speed ; Additional expansion available
  • [BUY & OWN WITH CONFIDENCE] - From the world's largest Microsoft Authorized Refurbisher; Quality Guarantee and Free Tech Support; Award-winning Customer Service; | Support Sustainable Business
  • [MODERN HI-SPEED PORTS] - USB 3.0 (x4) | USB 2.0 (x4) | DisplayPort (x1) | HDMI Port (x1) | Audio Combo Jack (x1) | Audio Out (x1) | RJ-45 Ethernet (x1) | Internal SATA (x3)

Python wrapper errors mentioning Xvfb or fonts

Cause: the wrapper has dependencies beyond the binary. Fix: install the system components named by that wrapper’s documentation, or use direct invocation when you do not need its API.

The download URL no longer works

Cause: release assets or runtime images changed. Fix: inspect the project’s current downloads and release pages, then choose an asset matching the live distribution and architecture. Pin the verified installation steps in a notebook cell so a future runtime change is visible rather than silently producing a different result.

8. Reliability, performance and cost in Colab

  • Runtime lifetime: installed software and generated PDFs live in the temporary runtime. Download outputs or copy them to durable storage before disconnecting.
  • Rendering time: large pages, remote assets and JavaScript delays increase conversion time. Prefer local, deterministic assets for repeatable reports.
  • Batching: loop over files or URLs in Python, capture each process’s return code, and retain stderr so one failed page does not look like a successful PDF.
  • Reproducibility: record the output of /etc/os-release, uname -m and wkhtmltopdf --version with your job logs.
  • Display requirements: wkhtmltopdf is headless; a desktop session is not normally required. A Python wrapper can still introduce Xvfb requirements.

9. Security rules for notebook conversions

The official downloads page warns not to use wkhtmltopdf with untrusted HTML and JavaScript without sanitizing it, because malicious input can lead to complete server takeover. Treat HTML, URLs, scripts, local assets and headers as hostile inputs. Do not embed secrets in generated pages or shell commands.

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

Colab documentation explains that code running through a connected runtime can access that runtime’s filesystem and advises users to trust notebook authors. Run installation and conversion cells only in notebooks you understand. Remove credentials and sensitive files before sharing or disconnecting the runtime.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is a clean capture rather than maintaining a Colab renderer, ScreenshotNeo is a website screenshot API and MCP server. One GET request returns a PNG, JPEG, WebP or PDF, while its capture process accepts consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and the response identifies the page verdict and billing status in headers.

Use the API directly (see the ScreenshotNeo documentation):

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

ScreenshotNeo also provides an MCP server for Claude, Cursor and other MCP clients, with take_screenshot, get_page_info and capture_pdf tools. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account to try it.

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

10. Safe, repeatable notebook checklist

  1. Inspect /etc/os-release and uname -m.
  2. Select a release asset matching both values.
  3. Install the .deb with apt and verify wkhtmltopdf --version.
  4. Create or upload UTF-8 HTML and keep local assets in a controlled directory.
  5. Run wkhtmltopdf input.html output.pdf, adding only the flags you need.
  6. Open or download the PDF and check fonts, images, page breaks and dynamic content.
  7. Remove secrets and sensitive files before sharing the notebook or disconnecting the runtime.

Frequently asked questions

Does wkhtmltopdf need Xvfb in Colab?

The renderer itself is headless and normally does not require a display service. A particular Python wrapper may list Xvfb as an additional dependency.

Best Value
Dell OptiPlex Computer Desktop PC, Intel Core i5 3rd Gen 3.2 GHz, 16GB RAM, 2TB HDD, New 22 Inch LED Monitor, RGB Keyboard and Mouse, WiFi, Windows 11 Pro (Renewed)
  • 🖥POWERFUL PROCESSOR and SUPERIOR STORAGE: Configured with top of the Intel Core i5 processor for lightning-fast, reliable and consistent performance to ensure an exceptional PC experience. 16GB RAM memory to smoothly run multiple applications and browser tabs all at once. 2TB HDD storage space to store apps, games, photos, music, and movies. Loaded with 16GB to zip through multiple tasks in a hurry without lag.
  • 🖥️New 22 Inch Full HD (1920x1080) LED monitor: with 75hz, High-Quality panel with quick refresh rate and response time. With 1080p resolution, you can enjoy gaming or a modern computing experience. 22 Inch monitor has a Smart Contrast to provide optimized image quality. Bezel-less and sleek design with glossy finish, crisp edge-to-edge visuals. Wide Viewing Angles for clarity from any viewpoint. VESA Mountable and built-in tilt options allow for a variety of monitor configurations.
  • ⌨️ +🖱️ RGB KEYBOARD AND MOUSE | RGB SPEAKER: 3 LED Colors - Blue, red, green, Backlight LED Lights for use at night time, looks amazing. The keyboard mouse and speaker are responsive, reliable, and probably plastered in RGB lights. It's important you pick the right one for your desktop.
  • 💿 WINDOWS 10 Pro LATEST: A new installation of the latest Microsoft Windows 11 Professional 64 Bit Operating System software, free of bloatware commonly installed from other manufacturers. As Microsoft's latest and best OS to date, Windows 10 Pro 64 Bit will maximize the utility of each PC for years to come. Optional software such as Anti-Virus and Office 365 can also be easily downloaded through the Microsoft Windows App Store.

Can I convert a private URL?

Only if the Colab runtime can authenticate and reach it. Supply credentials through secure mechanisms, not hard-coded notebook cells, and expect some modern authentication flows to be incompatible with Qt WebKit.

Where does Colab save the PDF?

Unless you choose another path, it is saved in the current runtime filesystem. Use google.colab.files.download or copy it to storage before the runtime ends.

Is 0.12.6 guaranteed to work on every Colab image?

No. It is the documented stable series released June 11, 2020; compatibility depends on the live distribution, architecture and libraries.

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

Frequently Asked Questions

Does wkhtmltopdf need Xvfb in Colab?

The renderer itself is headless and normally does not require a display service. A particular Python wrapper may list Xvfb as an additional dependency.

Can I convert a private URL?

Only if the Colab runtime can authenticate and reach it. Supply credentials through secure mechanisms, not hard-coded notebook cells, and expect some modern authentication flows to be incompatible with Qt WebKit.

Where does Colab save the PDF?

Unless you choose another path, it is saved in the current runtime filesystem. Use google.colab.files.download or copy it to storage before the runtime ends.

Is 0.12.6 guaranteed to work on every Colab image?

No. It is the documented stable series released June 11, 2020; compatibility depends on the live distribution, architecture and libraries.

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

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.