Skip to content

feat: 支援 HTML → PDF 轉換 (macdoc convert --to pdf) #69

Description

@kiki830621

Problem

macOS 內建工具都不支援 HTML → PDF:

  • textutil 不支援 PDF 輸出格式
  • cupsfilter 轉換失敗
  • weasyprint 需要 libgobject 等系統依賴,容易壞
  • Safari 無法開啟 ~/Music/Logic/ 等 macOS 保護目錄下的本地 HTML(WebKitErrorDomain:103「不允許使用受到限制的網路埠」)

目前 macdoc convert --to pdf input.html 回傳「不支援從 .html 轉換到 pdf」。

Type

feature

Expected

macdoc convert --to pdf input.html --output output.pdf

能正常將 HTML(含 CSS、ruby 標注等)轉成高品質 PDF。

Actual

Error: 不支援從 .html 轉換到 pdf

Proposed Approach

用 Process 呼叫 playwright pdf CLI(Chromium headless):

playwright pdf "file:///path/to/input.html" "/path/to/output.pdf" --paper-format A4

已驗證可行 — 在 melonsoda 歌詞專案中成功將含 ruby 讀音標注的 HTML 轉成 PDF。

Prerequisites

  • playwright CLI(pip install playwright && playwright install chromium)

Impact

  • 解決 macOS 保護目錄下 HTML 無法用 Safari 開啟/列印的問題
  • 補齊 macdoc convert 的格式支援矩陣(html → pdf)
  • melonsoda 專案 Makefile 的 make pdf 目前直接呼叫 playwright pdf,整合後可改用 macdoc convert

Current Status

Field Value
Phase closed
Updated 2026-04-01

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions