PDF Export & Printing
Relevant source files
The following files were used as context for generating this wiki page:
The PDF Export & Printing module in OpenHWP is designed to provide users with the ability to convert HWP and HWPX documents into PDF format and facilitate document printing through the native webview interface. This functionality is part of the project's phase 3 roadmap and leverages the underlying rhwp engine for high-fidelity export and the Chromium-based CEF backend for printing.
Sources: README.en.md:52-53, README.md:59-60
Architecture and Implementation
OpenHWP utilizes a decoupled architecture where document-specific logic is handled by the rhwp engine, while the desktop shell (built with Deno Desktop) manages user interaction and platform-specific capabilities.
Engine Integration
The rhwp engine, written in Rust and loaded as WebAssembly, is the primary component responsible for PDF generation. The desktop shell coordinates with this engine to process document data and output a PDF stream.
Printing Pathway
For printing, OpenHWP utilizes the "webview print path." Since the application uses the Chromium Embedded Framework (CEF) as its rendering backend, it inherits the standard Chromium printing capabilities, allowing documents rendered within the webview to be sent to native system print dialogs.
Sources: README.en.md:12-20, README.md:14-23, README.en.md:53
Export & Printing Flow
The following diagram illustrates the high-level flow of exporting a document to PDF and the printing process within the OpenHWP ecosystem.
This diagram shows the separation between PDF generation (via the engine) and printing (via the webview shell).
Sources: README.en.md:12-25, README.en.md:53, README.md:59-60
Key Components
The functionality relies on the integration of several core project technologies:
| Component | Responsibility | Source |
|---|---|---|
| rhwp engine | Core PDF generation and document parsing logic. | README.en.md:12 |
| CEF (Chromium) | Provides the rendering backend and the webview print path. | README.en.md:16 |
| Deno Desktop | Manages the native window and interfaces with the OS. | README.en.md:14 |
| File System Access API | Handles writing the exported PDF files to the local disk. | README.en.md:21-25 |
Sources: README.en.md:12-25, README.en.md:53
Technical Requirements and Dependencies
The export and printing features are dependent on the specific toolchain and rendering backend selected for OpenHWP:
- Deno Runtime: Requires Deno version ≥ 2.9.0 to support
deno desktopfeatures. - CEF Backend: The project explicitly uses
"backend": "cef"indeno.jsonto ensure consistent rendering and access to modern web APIs required for the printing path across different operating systems (macOS, Windows, Linux). - rhwp WebAssembly: The PDF export logic is embedded within the
@rhwp/coreor@rhwp/editorpackages, which are imported into the desktop shell.
Sources: CONTRIBUTING.md:11-13, README.en.md:16-20, README.md:18-23
Roadmap and Status
As of the current project state, PDF Export and Printing are defined as priority items in the stage 3 roadmap.
The sequence diagram details the interaction between the user, the shell, the WASM engine, and the underlying operating system during export and print operations.
Sources: README.en.md:38-48, README.en.md:53, README.md:59-60
Conclusion
PDF Export & Printing in OpenHWP bridges the gap between digital HWP processing and physical/standardized output. By utilizing rhwp for PDF generation and the Chromium-based CEF for printing, the project ensures a consistent and high-fidelity experience across all supported desktop platforms without requiring proprietary software.
Sources: README.en.md:5-9, README.en.md:53