Skip to main content

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 experimental. Output and APIs may change. If you hit an exporter limitation or confusing output, reach out on Discord.
PDF export is only available in native (non-WASM) builds. The printpdf crate used for PDF generation does not support WebAssembly targets.

PdfExportConfig

Structure

Configuration for PDF export operations.

Default Configuration

Defaults to A4 landscape with 10mm margins and 0.25mm line width.

Predefined Page Sizes

a4_portrait

210mm × 297mm (standard A4 portrait)

a4_landscape

297mm × 210mm (standard A4 landscape, same as default)

a3_landscape

420mm × 297mm (large format)

custom

Custom page dimensions in millimeters.

Configuration Examples

Export Functions

export_scene_to_pdf

Export a Scene2D to PDF with default configuration. Example (Rust):

export_scene_to_pdf_with_config

Export with custom configuration. Example (Rust):

export_brep_to_pdf_with_camera

Combined projection and export in a single operation. Example (Rust):

export_scene_to_pdf_bytes

Export to memory instead of file (useful for web servers or in-memory processing). Example (Rust):

Scene Manager Integration

projectToPDF (Native Only)

The OGSceneManager provides a convenience method that projects and exports in one call. Example (Node.js):

Error Handling

PdfExportError

DocumentCreation: Failed to create PDF structure FileWrite: Failed to write to output file EmptyScene: Attempted to export a scene with no visible geometry InvalidConfig: Configuration is invalid (e.g., margins larger than page)

Handling Errors (Rust)

Coordinate System & Scaling

Units

  • Input Scene: Meters (from 3D projection)
  • PDF Output: Millimeters
  • Conversion: 1 meter = 1000 millimeters

Auto-Fit Behavior

When auto_fit: true (default):
  1. Calculate scene bounding box
  2. Calculate drawable area: page_size - 2 × margin
  3. Compute scale factor to fit scene within drawable area
  4. Apply uniform scaling (maintains aspect ratio)
  5. Center the scaled drawing on the page

1:1 Scale Export

With auto_fit: false, 1 meter in the scene = 1000mm on the PDF (may overflow page).

Styling & Appearance

Line Width

Global line width is set via config.line_width_mm. Individual paths can override this:

Line Color

Paths can specify custom stroke colors:
Colors are specified as (r, g, b) tuples with values from 0.0 to 1.0.

Document Metadata

The PDF title is set from:
  1. config.title if provided
  2. scene.name if available
  3. "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:
  1. Verify scene is not empty: !scene.is_empty()
  2. Check scene bounding box: scene.bounding_box()
  3. Ensure geometry is within camera view
  4. Verify camera near plane doesn’t clip all geometry
  5. Check HLR isn’t hiding all edges

Platform Availability

WASM Alternative

For web applications, export Scene2D as JSON and render using canvas/SVG:
Last modified on March 14, 2026