Overview
The PDF export system converts projected 2D scenes to vector PDF documents. All output is true vector graphics with no rasterization, suitable for technical drawings, CAD exports, and high-quality prints.PDF export is only available in native (non-WASM) builds. The
printpdf crate used for PDF generation does not support WebAssembly targets.PdfExportConfig
Structure
Default Configuration
Predefined Page Sizes
a4_portrait
a4_landscape
a3_landscape
custom
Configuration Examples
Export Functions
export_scene_to_pdf
export_scene_to_pdf_with_config
export_brep_to_pdf_with_camera
export_scene_to_pdf_bytes
Scene Manager Integration
projectToPDF (Native Only)
Error Handling
PdfExportError
Handling Errors (Rust)
Coordinate System & Scaling
Units
- Input Scene: Meters (from 3D projection)
- PDF Output: Millimeters
- Conversion: 1 meter = 1000 millimeters
Auto-Fit Behavior
Whenauto_fit: true (default):
- Calculate scene bounding box
- Calculate drawable area:
page_size - 2 × margin - Compute scale factor to fit scene within drawable area
- Apply uniform scaling (maintains aspect ratio)
- Center the scaled drawing on the page
1:1 Scale Export
auto_fit: false, 1 meter in the scene = 1000mm on the PDF (may overflow page).
Styling & Appearance
Line Width
Global line width is set viaconfig.line_width_mm. Individual paths can override this:
Line Color
Paths can specify custom stroke colors:(r, g, b) tuples with values from 0.0 to 1.0.
Document Metadata
The PDF title is set from:config.titleif providedscene.nameif available"OpenGeometry Export"as fallback
Complete Export Example (Rust)
Multi-View Technical Drawing (Rust)
Best Practices
Page Size Selection
- A4 (210×297mm): Standard documents, small to medium models
- A3 (297×420mm): Larger models, detailed drawings
- Custom: Use when specific output size is required
Line Width Guidelines
- 0.18mm: Fine detail, small scale
- 0.25mm: Standard technical drawings (default)
- 0.35mm: Bold lines, large format prints
- 0.5mm+: Emphasis lines, thick outlines
Margins
- 10mm: Standard (default)
- 15-20mm: Professional presentations
- 5mm: Maximum content area
Quality Optimization
Troubleshooting Empty PDFs
If your PDF is blank:- Verify scene is not empty:
!scene.is_empty() - Check scene bounding box:
scene.bounding_box() - Ensure geometry is within camera view
- Verify camera near plane doesn’t clip all geometry
- Check HLR isn’t hiding all edges
Platform Availability
| Platform | Support | Notes |
|---|---|---|
| Native Rust | ✅ Full | All export functions available |
| Node.js (napi) | ✅ Full | Via projectToPDF method |
| Browser/WASM | ❌ None | Use Scene2D JSON for client-side rendering |
WASM Alternative
For web applications, export Scene2D as JSON and render using canvas/SVG:Related
- Projection - Creating 2D scenes from 3D geometry
- Scene Management - Organizing geometry entities
- BRep - Boundary representation structure