webkit-pdf-snap

command
v0.6.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

webkit-pdf-snap

Zero-CGo (CGO_ENABLED=0), zero-TCC headless HTML/CSS/SVG → vector PDF & PNG snapshot pipeline with PDFKit inspection and Vision OCR round-trip verification — no Chrome or Playwright binary required.

What It Does

  1. Boots a headless NSApplication (NSApplicationActivationPolicyProhibited) with an offscreen WKWebView.
  2. Renders an inline HTML+CSS+SVG card by default (offline), or a -html file / -url.
  3. Exports a vector PDF (CreatePDFWithConfigurationCompletionHandler) and inspects page/text counts via PDFKit.
  4. Captures a PNG snapshot (TakeSnapshotWithConfigurationCompletionHandler) and runs VNRecognizeTextRequest OCR on the rendered pixels to verify round-trip text fidelity.

Usage

# Zero-friction offline run on built-in HTML+SVG card:
CGO_ENABLED=0 go run ./examples/webkit/webkit-pdf-snap

# Render a local HTML file or URL:
CGO_ENABLED=0 go run ./examples/webkit/webkit-pdf-snap -html card.html -pdf out.pdf -png snap.png
CGO_ENABLED=0 go run ./examples/webkit/webkit-pdf-snap -url https://example.com -width 1024 -height 768

Flags:

  • -url — URL to render (default: built-in HTML+SVG card)
  • -html — local HTML file to render
  • -pdf — output PDF path (default: temp dir)
  • -png — output PNG snapshot path (default: temp dir)
  • -width, -height — viewport dimensions in points (default 760 × 360)

Sample Output

Source: inline HTML+SVG card (760x360, 17.679s)
PDF:    /var/folders/.../render.pdf (17505 bytes, 1 page(s), 189 text chars via PDFKit)
PNG:    /var/folders/.../snapshot.png (39707 bytes, 760x360)
OCR:    7 lines recognized -> "ZERO-CGO MACOS | WebKit Headless PDF & Snapshot | Rendered offline via WKWebView, inspected with PDFKit, and verified by Vision OCR. | Vector PDF | WKPDFConfiguration | Vision OCR | Round-Trip Verified"

Documentation

Rendered for darwin/amd64

Overview

Command webkit-pdf-snap renders HTML/CSS/SVG or a URL headlessly with WebKit to a vector PDF and PNG snapshot, then verifies the output using PDFKit and Vision OCR—without Chrome or Playwright.

Usage:

webkit-pdf-snap [-url URL | -html file.html] [-pdf out.pdf] [-png out.png]

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL