Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
H

html2svg

> 编程语言
Open source

Convert HTML and `<canvas>` to SVG, PDF, or images using Chromium

1.3K stars0 likes2 views
WebsiteGitHub

About

Convert HTML and `<canvas>` to SVG, PDF, or images using Chromium

html2svg

Convert HTML and `` to vector (SVG, PDF) or bitmap (PNG, JPEG, WebP) images using Chromium. Read the blog post.

Usage

…

Server

An HTTP server is also provided, all CLI options are supported:

…

Development

Building Chromium is only officially supported on AMD64. If you'd like to target ARM64, cross-compile from AMD64 instead.

Local

You'll need to install all tools required to build Chromium: https://www.chromium.org/developers/how-tos/get-the-code/

If you're running Linux, you can use the Docker build instructions to generate binaries.

  1. Fetch dependencies:
    bash
    $ yarn
  2. Clone Electron.js and Chromium using gclient:
    bash
    $ yarn gclient
  3. Configure the build system using gn using one of these commands:
    bash
    # for local developement
    $ yarn gn testing
    # or for releasing
    $ yarn gn release
    # add --ide=xcode if you'd like to generate an Xcode project on macOS
    $ yarn gn release --ide=xcode
  4. Build using ninja using one of these commands:
    bash
    # make a testing build
    $ yarn ninja testing
    # make a release build
    $ yarn ninja release

Docker

We use docker run instead of Dockerfile for building Chromium to support incremental building.

bash
# Create the build environment
$ docker build . --build-arg "WORKDIR=$(pwd)" --target build-env --tag html2svg-build-env
# Clone the Chromium/Electron code
$ docker run -ti -v $(pwd):$(pwd) html2svg-build-env scripts/gclient.sh --revision "src/electron@cb22573c3e76e09df9fbad36dc372080c04d349e"
# Apply html2svg patches
$ docker run -ti -v $(pwd):$(pwd) html2svg-build-env scripts/patch.sh
# Install build dependencies
$ docker run -ti -v $(pwd):$(pwd) html2svg-build-env electron/src/build/install-build-deps.sh

Now you'll have to build binaries, steps differs depending on the platform you'd like to target:

  • AMD64:
    bash
    # Fetch compiler files
    $ docker run -ti -v $(pwd):$(pwd) html2svg-build-env electron/src/build/linux/sysroot_scripts/install-sysroot.py --arch=amd64
    # Generate build files
    $ docker run -ti -v $(pwd):$(pwd) --workdir $(pwd)/electron/src html2svg-build-env gn gen "out/release-amd64" --args="import(\"//electron/build/args/release.gn\") cc_wrapper=\"ccache\""
    # Build binaries
    $ docker run -ti -v $(pwd):$(pwd) html2svg-build-env scripts/build.sh release-amd64
  • ARM64:
    bash
    # Fetch compiler files
    $ docker run -ti -v $(pwd):$(pwd) html2svg-build-env electron/src/build/linux/sysroot_scripts/install-sysroot.py --arch=arm64
    # Generate build files
    $ docker run -ti -v $(pwd):$(pwd) --workdir $(pwd)/electron/src html2svg-build-env gn gen "out/release-arm64" --args="import(\"//electron/build/args/release.gn\") cc_wrapper=\"ccache\" target_cpu=\"arm64\""
    # Build binaries
    $ docker run -ti -v $(pwd):$(pwd) html2svg-build-env scripts/build.sh release-arm64 --target-cpu=arm64

Finally, build the Docker image:

bash
docker build .

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言