Skip to main content

ses_pdf/
lib.rs

1//! Professional PDF report engine for structural engineering calculations.
2//!
3//! `ses-pdf` compiles a structured document model into a publication-quality PDF
4//! using the [Typst](https://typst.app) typesetting engine under the hood.
5//! Reports can contain:
6//!
7//! - Engineering equations with Typst math notation
8//! - Calculation blocks (formula → substitution → numeric result)
9//! - Data tables with shaded headers
10//! - Line, bar, scatter, and P-M interaction charts (vector SVG)
11//! - User-supplied images and SVG figures
12//! - Cover page, section numbering, headers, footers, and page numbers
13//! - Drawing sheets with Arch paper sizes, landscape orientation, and title blocks
14//!
15//! # Quick start
16//!
17//! ```rust,no_run
18//! use ses_pdf::*;
19//!
20//! let pdf_bytes = Report::new(ReportMetadata {
21//!     project_name:   "Grid B5 Beam".into(),
22//!     project_number: "2025-001".into(),
23//!     prepared_by:    "SES Engineering".into(),
24//!     checked_by:     None,
25//!     date:           "March 14, 2025".into(),
26//!     paper:          PaperSize::Letter,
27//!     orientation:    Orientation::Portrait,
28//! })
29//! .section(
30//!     Section::new("Moment Capacity")
31//!         .text("Nominal moment capacity per ACI 318-19 Section 22.2.")
32//!         .equation(Equation::display("phi M_n = phi dot A_s dot f_y dot (d - a/2)"))
33//!         .calc(
34//!             CalcBlock::new("Nominal Moment Capacity")
35//!                 .formula("M_n = A_s f_y (d - a/2)")
36//!                 .substitution("M_n = (0.60)(60)(14.5 - 1.25)")
37//!                 .result("M_n = 477 \"kip-in\"")
38//!                 .build()
39//!                 .unwrap(),
40//!         ),
41//! )
42//! .render()
43//! .unwrap();
44//!
45//! std::fs::write("report.pdf", pdf_bytes).unwrap();
46//! ```
47//!
48//! # Drawing sheets
49//!
50//! Attach a [`TitleBlock`] and choose an Arch paper size with landscape orientation
51//! for structural drawing sheets. Page chrome switches to a sheet border and title
52//! block footer instead of calculation-report headers.
53//!
54//! Supported Arch sizes: [`PaperSize::ArchA`] … [`PaperSize::ArchE`], [`PaperSize::ArchE1`].
55//!
56//! # Math notation
57//!
58//! Equations use **Typst math syntax**, not LaTeX:
59//!
60//! | LaTeX | Typst |
61//! |-------|-------|
62//! | `\phi` | `phi` |
63//! | `\frac{a}{b}` | `a/b` |
64//! | `\sqrt{x}` | `sqrt(x)` |
65//! | `\times` | `times` |
66//! | Display math `\[ ... \]` | `$ ... $` (spaces inside) |
67//! | `A_{cv}` (multi-letter sub) | `A_"cv"` |
68//!
69//! See the [Typst math documentation](https://typst.app/docs/reference/math/) for the full reference.
70
71#![forbid(unsafe_code)]
72
73pub mod chart;
74pub mod element;
75
76mod error;
77mod markup;
78mod report;
79mod world;
80
81pub use chart::{
82    BarChart, BarSeries, Chart, ChartColor, DemandPoint, LineChart, LineSeries,
83    PmInteractionDiagram, ScatterChart, ScatterSeries,
84};
85pub use element::{
86    CalcBlock, CalcBlockBuilder, CalcStatus, CellAlign, CellValue, ColumnSpec, ColumnWidth,
87    Equation, Figure, HeadingLevel, ImageFormat, Table, TableBuilder,
88};
89pub use error::PdfError;
90pub use report::{
91    CoverPage, Orientation, PaperSize, Report, ReportMetadata, Section, TitleBlock,
92};