momo2023
V2EX  ›  问与答

html 转 pdf,有哪些好用的工具推荐?

  •  
  •   momo2023 · Oct 29, 2025 · 3059 views
    This topic created in 381 days ago, the information mentioned may be changed or developed.
    Supplement 1  ·  Oct 30, 2025
    补充,是想用在 Python 环境下的批量处理,手动 Chrome 转换不太高效
    13 replies  •  2025-12-14 21:23:20 +08:00
    ulyssess
    ulyssess
    Oct 29, 2025
    1
    html2pdf
    coder001
    coder001
    Oct 29, 2025
    2
    Chrome , 打印到 PDF
    Aalen
    Aalen
    Oct 29, 2025
    3
    ctrl+p
    qgmzmy
    qgmzmy
    Oct 29, 2025 via iPhone
    4
    直接用浏览器
    pike0002
    pike0002
    Oct 29, 2025
    5
    浏览器插件 Page Saver
    locoz
    locoz
    Oct 29, 2025 via Android
    8
    jifengg
    jifengg
    Oct 30, 2025
    9
    不考虑超轻量的话,建议是使用 chrome 系。
    理由是可以所见所得,这个会省去你好多调试版式的时间。

    手动,chrome 直接打印到 pdf
    命令行,用 chrome 的 headless 模式
    开发,用 puppeteer 等封装 chrome(chromium)的库
    songteng0604
    songteng0604
    Oct 30, 2025
    10
    pandoc example.html -o output.pdf
    zw2019
    zw2019
    Oct 30, 2025
    11
    https://html2pdf.iwlz.de/

    用 html2pdf 写的,由于在 linux 中运行没有 windows 的一些字体,可能生成的 pdf 的字体不一样。

    有没有要买 vps 的 rn dc03 洛杉矶一年才 10.96 https://v2ex.com/t/1164248
    songteng0604
    songteng0604
    Oct 30, 2025
    12
    刚刚我亲测了一下,借助 Grok ,在 win10 上,html 内容有中文,依然正常转为 pdf 。首先,我使用 powershell+scoop 安装了 miktex ,然后执行下面这个命令,即可完成转换。过程中可能会提醒安装一些宏包。

    pandoc example.html -o output.pdf `
    --pdf-engine=xelatex `
    -V mainfont="SimSun" `
    -V CJKmainfont="SimSun" `
    -V geometry:margin=1in
    Twitf
    Twitf
    Dec 14, 2025
    13
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1107 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 23:11 · PVG 07:11 · LAX 15:11 · JFK 18:11
    ♥ Do have faith in what you're doing.