Skip to content

render: expose native PDF export API#1359

Open
seo-rii wants to merge 5 commits into
edwardkim:develfrom
seo-rii:render-p23
Open

render: expose native PDF export API#1359
seo-rii wants to merge 5 commits into
edwardkim:develfrom
seo-rii:render-p23

Conversation

@seo-rii

@seo-rii seo-rii commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

What

P23 단계로 PDF export를 native API 표면에 올렸습니다.

  • DocumentCore::render_page_pdf_native(page)를 추가했습니다.
  • DocumentCore::render_pages_pdf_native(&[page])를 추가해 0-based 명시 page selection을 지원합니다.
  • DocumentCore::render_document_pdf_native()를 추가해 전체 문서 PDF export를 한 API로 호출할 수 있게 했습니다.
  • CLI export-pdf가 SVG를 직접 모아서 renderer::pdf를 호출하지 않고, 위 native API를 사용하도록 바꿨습니다.
  • export-pdf의 출력 디렉터리 생성/변환/저장 실패 경로가 실패 뒤에 완료 메시지를 찍지 않도록 정리했습니다.
  • PDF export contract 테스트를 추가했습니다.
  • render-diff CI에 report-only PDF visual diff를 추가했습니다. export-pdf 결과를 pdftoppm으로 PNG rasterize한 뒤 browser Canvas 출력과 비교하고, JSON/Markdown summary와 reference/PDF/raster/diff artifacts를 업로드합니다.

Why

P22까지는 renderer boundary cleanup이 중심이었습니다. 다음 단계에서는 PDF를 PNG raster export와 별도 출력 계약으로 보고, 우선 기존 SVG-derived PDF 변환기를 DocumentCore native API로 안정화하는 게 맞다고 봤습니다.

이 PR은 direct/vector PageLayerTree -> PDF backend를 바로 여는 PR이 아니라, CLI와 native caller가 같은 PDF export surface를 쓰도록 정리하는 단계입니다. PDF visual diff도 같은 이유로 hard gate가 아니라 report-first로 둡니다. 지금은 PDF/Canvas rasterizer 차이를 수치와 artifact로 모으는 단계입니다.

Non-goals

  • WASM public API에 PDF bytes export를 추가하지 않습니다.
  • direct/vector PageLayerTree -> PDF replay backend를 추가하지 않습니다.
  • PDF visual diff를 CI hard gate로 만들지 않습니다.
  • Swift/XCFramework/FFI packaging 자체를 바꾸지 않습니다. 이번 변경은 Rust native API와 CLI 표면 정리입니다.
  • PDF 출력 자체를 한컴 시각 정답지로 선언하지 않습니다.

Compatibility

  • 기존 CLI 명령은 그대로 rhwp export-pdf <file> [-o out.pdf] [-p page] 형식을 유지합니다.
  • -p는 기존처럼 0-based 단일 페이지 선택입니다.
  • -p가 없으면 전체 문서를 다중 페이지 PDF로 내보냅니다.
  • 내부 PDF 변환은 기존 SVG-derived svg2pdf + pdf-writer 경로를 유지합니다.
  • 기존 Canvas visual diff는 계속 hard gate로 유지하고, PDF visual diff는 같은 artifact 흐름에 report-only summary만 추가합니다.

Validation

  • cargo fmt --check
  • node --check rhwp-studio/e2e/canvas-render-diff.test.mjs && node --check rhwp-studio/e2e/pdf-render-diff-report.mjs && node --check rhwp-studio/e2e/run-render-diff.mjs
  • CARGO_INCREMENTAL=0 cargo test --test render_p23_pdf_export_contract -- --nocapture
  • cargo build --bin rhwp
  • RHWP_RENDER_DIFF_SKIP_CANVAS=1 RHWP_RENDER_DIFF_PDF=1 RHWP_RENDER_DIFF_FILES=basic/KTX.hwp RHWP_RENDER_DIFF_MAX_PAGES=1 RHWP_RENDER_DIFF_RHWP_BIN=../target/debug/rhwp npm run e2e:render-diff:ci
  • RHWP_RENDER_DIFF_PDF=1 RHWP_RENDER_DIFF_FILES=basic/KTX.hwp RHWP_RENDER_DIFF_MAX_PAGES=1 RHWP_RENDER_DIFF_RHWP_BIN=../target/debug/rhwp npm run e2e:render-diff:ci
  • CARGO_INCREMENTAL=0 cargo check --bin rhwp
  • CARGO_INCREMENTAL=0 cargo check --lib --target wasm32-unknown-unknown -j 2
  • cargo run --bin rhwp -- export-pdf samples/re-03-latin-only-hancom.hwp -o output/render-p23-smoke.pdf -p 0

Refs #536

@edwardkim edwardkim self-requested a review June 10, 2026 14:32
@edwardkim edwardkim added the enhancement New feature or request label Jun 10, 2026
@edwardkim edwardkim added this to the v1.0.0 milestone Jun 10, 2026
@seo-rii seo-rii marked this pull request as ready for review June 11, 2026 13:54
Copilot AI review requested due to automatic review settings June 11, 2026 13:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR introduces native PDF export APIs on DocumentCore (implemented via the existing SVG → svg2pdf compatibility path), updates the CLI export-pdf command to use those APIs, and adds contract tests/docs to lock behavior.

Changes:

  • Added DocumentCore native PDF export APIs: single page, explicit page selection, and full-document export.
  • Updated CLI export-pdf to call the new native PDF export path and improved directory creation error handling.
  • Added Rust tests asserting PDF-byte shape and error contracts; updated docs/README milestone notes.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/render_p23_pdf_export_contract.rs Adds contract tests for native PDF export output and error behavior.
src/main.rs Switches CLI PDF export to render_pages_pdf_native and improves I/O error handling.
src/document_core/queries/rendering.rs Adds native DocumentCore PDF export APIs built on SVG-derived rendering.
mydocs/manual/cli_commands.md Documents updated CLI PDF export behavior and the underlying native API path.
README_EN.md Updates milestone notes to describe P23 PDF export promotion to native APIs.
README.md Updates milestone notes to describe P23 PDF export promotion to native APIs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main.rs Outdated
Comment thread tests/render_p23_pdf_export_contract.rs
Comment thread src/document_core/queries/rendering.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants