Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsTo create a PDF from HTML in Go, run a Chrome-compatible browser and use the Chrome DevTools Protocol command Page.printToPDF. The chromedp package lets Go control that browser; Chrome does the HTML rendering and produces the PDF bytes. For an application that should send HTML or a URL to a separate conversion service instead, Gotenberg provides a Docker-based HTTP API.
Choose how Go will reach the HTML
There are two common architectures, depending on where your HTML lives and who should operate the browser:
As an Amazon Associate I earn from qualifying purchases.
- Use chromedp when your Go process should drive a browser directly, with browser actions and PDF options controlled in Go.
- Use Gotenberg when you prefer to submit HTML files and assets, or a hosted URL, to a separately deployed conversion API.
In both cases a browser renders the HTML. The difference is whether browser control and deployment sit with your Go application or behind an HTTP service.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Create a PDF with chromedp
chromedp is a Go driver for browsers that support the Chrome DevTools Protocol. Install it using Go modules and make a compatible Chrome browser available to the application. Chrome runs headlessly by default; the project documents its headless-shell image as an option for headless deployments.
#1 Best Overall
- 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
Minimal complete example
This example navigates to a URL, waits for navigation actions to finish, asks Chrome for PDF bytes, and writes them to a file. Replace the URL with a page your browser process can access.
package main
import (
"context"
"log"
"os"
"time"
"github.com/chromedp/chromedp"
"github.com/chromedp/cdproto/page"
)
func main() {
ctx, cancel := chromedp.NewContext(context.Background())
defer cancel()
ctx, cancel = context.WithTimeout(ctx, 60*time.Second)
defer cancel()
var pdfBytes []byte
err := chromedp.Run(ctx,
chromedp.Navigate("https://example.com"),
chromedp.ActionFunc(func(ctx context.Context) error {
data, _, err := page.PrintToPDF().Do(ctx)
if err != nil {
return err
}
pdfBytes = data
return nil
}),
)
if err != nil {
log.Fatal(err)
}
if err := os.WriteFile("output.pdf", pdfBytes, 0o644); err != nil {
log.Fatal(err)
}
}
The print call follows the official chromedp example’s flow: create a browser context, run navigation and an action that calls page.PrintToPDF().Do(ctx), then save the returned bytes. The timeout makes the operation bounded; tune it to your application and page behavior. In a service, return errors to the caller rather than using log.Fatal, which terminates the process.
Wait for the document you intend to print
A completed navigation does not necessarily mean a single-page application has finished rendering, fonts or images have loaded, or asynchronous content is ready. Add an explicit readiness condition before printing. For example, wait for a selector that your page displays only after its content is prepared:
Free tools Windows power users keep installed
One-click scans. No signup required.
err := chromedp.Run(ctx,
chromedp.Navigate(targetURL),
chromedp.WaitVisible("#report-ready", chromedp.ByID),
chromedp.ActionFunc(func(ctx context.Context) error {
data, _, err := page.PrintToPDF().Do(ctx)
if err != nil {
return err
}
pdfBytes = data
return nil
}),
)
Use a readiness signal meaningful to the page, not an arbitrary fixed sleep, where possible. If your HTML is generated locally, make it available to the browser through a suitable loading method and ensure relative stylesheets, fonts, and images resolve. The URL-navigation example does not establish that every local-file arrangement or asset path will work unchanged.
Rank #2
- 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⁴
Set page dimensions and print behavior deliberately
Page.printToPDF exposes paper width and height in inches, margins, orientation, scale, page ranges, header and footer HTML, CSS page-size preference, tagged PDF generation, document outlines, and transfer mode. Page ranges are one-based. The generated protocol API lists print backgrounds, tagged output, and document outlines as disabled by default; CSS page size is not preferred by default, so the browser may scale content to the selected paper dimensions.
For example, to print backgrounds and prefer dimensions declared by CSS @page, set those options explicitly:
data, _, err := page.PrintToPDF().
WithPrintBackground(true).
WithPreferCSSPageSize(true).
Do(ctx)
Use the generated Page.printToPDF options available in the version of cdproto used by your application to configure other settings. Decide whether the document needs portrait or landscape layout, specific paper dimensions, margins, scaling, headers or footers, a page range, tags, or an outline. CSS page rules and protocol settings can interact, so inspect actual PDFs made from representative pages, including long tables, page breaks, fonts, and images.
Use Gotenberg as a separate conversion service
Gotenberg packages document conversion behind a Docker-based HTTP API. Your Go application makes a multipart form request to the service rather than directly managing the browser process. This can be useful when your team wants a distinct deployment boundary for browser installation, fonts, and conversion.
Rank #3
- 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.
Convert HTML files and supporting assets
For HTML input, Gotenberg’s Chromium endpoint is POST /forms/chromium/convert/html. The request requires a file named index.html; supporting assets can be supplied with the document. The service documents controls for paper layout, print backgrounds, waiting, and handling failed resources or HTTP status codes. See Gotenberg’s documentation for the precise multipart field names and options for the version you deploy.
Convert a hosted URL
For an already hosted page, use POST /forms/chromium/convert/url and provide the required URL form value. Gotenberg documents JavaScript execution and support for dynamic pages and single-page applications. The URL route rejects file:// URLs; for local HTML, use its HTML or Markdown conversion route instead.
Gotenberg documents a default page size of 8.5 by 11 inches and margins of 0.39 inches; print backgrounds default to false. Specify layout settings when those defaults do not match the document. The service also needs access to the submitted assets and any network resources the page requires.
Compare the two deployment approaches
| Decision | chromedp in Go | Gotenberg |
|---|---|---|
| Interface | Go code drives Chrome DevTools Protocol directly. | HTTP multipart requests to conversion endpoints. |
| Browser ownership | Your application deployment must provide access to a compatible browser; chromedp documents headless-shell as an option. | The browser is part of a separately deployed Docker-based API. |
| Control style | Direct browser actions and protocol options from Go. | Centralized routes and form options for HTML, URL, and output behavior. |
| Best fit | You need browser control in Go and can support the browser in the app runtime. | You want to isolate rendering behind an HTTP service and operate that service separately. |
go-rod/rod is another Go driver for Chrome DevTools Protocol; its official examples include PDF methods such as Page.PDF and MustPDF. It is worth comparing if you are choosing a browser-driver API.
Rank #4
- 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
Common failures and how to diagnose them
- Browser connection closes or the context is canceled: Check that the browser process remains alive and that the context deadline allows navigation and rendering to complete. chromedp documents that a lost or terminated browser connection cancels its context.
- PDF is blank or missing dynamic content: Do not assume navigation completion means the app has rendered. Wait for a page-specific selector or readiness signal before calling
PrintToPDF. - Background colors or images are absent: Enable print backgrounds explicitly; the protocol API option defaults to disabled.
- Content is scaled unexpectedly or margins are wrong: Set paper size, margins, scale, and CSS page-size preference intentionally. The protocol does not prefer CSS page size by default.
- Images, fonts, or styles are missing: Confirm the browser or conversion service can reach the asset URLs and that local HTML paths resolve from its runtime. For Gotenberg HTML uploads, include supporting assets with the document as needed.
- Gotenberg rejects a local file URL: Its URL conversion route does not accept
file://; submit the HTML through the HTML or Markdown route instead. - Output differs across pages or content lengths: Inspect real PDFs with long tables, varied page breaks, fonts, and images, then adjust print CSS and PDF options. Available settings do not guarantee a particular template will paginate as intended.
Performance, reliability, and cost considerations
The available documentation describes these conversion mechanisms and controls, but does not establish a universal speed, reliability rate, or cost comparison. Measure with your own representative pages and deployment. For chromedp, account for browser startup and resource use in the Go service’s runtime; for Gotenberg, account for operating and scaling a separate Docker service. In either design, bound work with timeouts, handle browser or HTTP failures, and decide how retries should avoid duplicating downstream work.
Or skip the browser setup
For a hosted page, ScreenshotNeo provides a website screenshot API and MCP server. A single GET request can return a clean screenshot or PDF; the example below is the documented screenshot request and saves a WebP image, not a PDF.
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 PDF capture options and the other request parameters. ScreenshotNeo accepts cookie/consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients.
The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Visit ScreenshotNeo or sign up free.
Frequently Asked Questions
Can I create a PDF from an HTML template that is not hosted publicly?
Yes. With chromedp, make the HTML available to the browser and ensure its relative assets resolve. With Gotenberg, submit the HTML and supporting assets through its HTML conversion route; its URL route does not accept file:// URLs.
Does chromedp render HTML itself?
No. chromedp is the Go browser-control client; a Chrome-compatible browser renders the page and generates the PDF.
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.
Recommended Free Tools




