render: expose native PDF export API#1359
Open
seo-rii wants to merge 5 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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
DocumentCorenative PDF export APIs: single page, explicit page selection, and full-document export. - Updated CLI
export-pdfto 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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로 호출할 수 있게 했습니다.export-pdf가 SVG를 직접 모아서renderer::pdf를 호출하지 않고, 위 native API를 사용하도록 바꿨습니다.export-pdf의 출력 디렉터리 생성/변환/저장 실패 경로가 실패 뒤에 완료 메시지를 찍지 않도록 정리했습니다.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 변환기를
DocumentCorenative API로 안정화하는 게 맞다고 봤습니다.이 PR은 direct/vector
PageLayerTree -> PDFbackend를 바로 여는 PR이 아니라, CLI와 native caller가 같은 PDF export surface를 쓰도록 정리하는 단계입니다. PDF visual diff도 같은 이유로 hard gate가 아니라 report-first로 둡니다. 지금은 PDF/Canvas rasterizer 차이를 수치와 artifact로 모으는 단계입니다.Non-goals
PageLayerTree -> PDFreplay backend를 추가하지 않습니다.Compatibility
rhwp export-pdf <file> [-o out.pdf] [-p page]형식을 유지합니다.-p는 기존처럼 0-based 단일 페이지 선택입니다.-p가 없으면 전체 문서를 다중 페이지 PDF로 내보냅니다.svg2pdf + pdf-writer경로를 유지합니다.Validation
cargo fmt --checknode --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.mjsCARGO_INCREMENTAL=0 cargo test --test render_p23_pdf_export_contract -- --nocapturecargo build --bin rhwpRHWP_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:ciRHWP_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:ciCARGO_INCREMENTAL=0 cargo check --bin rhwpCARGO_INCREMENTAL=0 cargo check --lib --target wasm32-unknown-unknown -j 2cargo run --bin rhwp -- export-pdf samples/re-03-latin-only-hancom.hwp -o output/render-p23-smoke.pdf -p 0Refs #536