Skip to main content

Module pdf

Module pdf 

Source
Expand description

The whole document as a PDF: one page per scope, the navigation hierarchy as the PDF outline, and a link annotation over every block that opens a scope — so the diagram navigates inside any ordinary PDF reader, and review rides that reader’s own annotation tools rather than anything the app ships.

Pages are drawn by the existing SVG export path (crate::level::render_level) and placed with krilla-svg. Nothing here knows how a block looks; a second renderer would drift from the editor’s, and the editor’s is the one users check their drawings against.

Structs§

At 🔒
Where one of the block’s lines goes: the left edge of its caption, the baseline it sits on, and the width of the caption column beside it.
Column 🔒
One column of the block, measured: its cells as they will be drawn, how wide its captions are, and how wide the column ends up.
Fit
How a scope’s world-space frame is placed on its page: at a given scale, centred in the content box. Page coordinates are krilla’s — points, y down from the page’s top-left corner.
Kept 🔒
Which of a path’s segments a line had room for.
Laid 🔒
One cell placed on its line: what it draws, and — for a path — which of its segments survived the fit.
Measured 🔒
The backend’s text extents in the family and size the block is set in — the layout that measures what krilla draws.
Page 🔒
Everything one page is drawn from.
Placed 🔒
Where a line’s value was set: its left edge and the line box it fills.
Printed 🔒
What printing the title block leaves behind for the page to place: the rule around it, and a link over each ancestor segment of its Path row.
Scene
What a PDF export is taken from.
Scoped 🔒
A scope and the scopes it holds: the navigator’s hierarchy, with a page number attached to each node.
Sheet
One scope’s sheet: cut to the drawing it holds — the scope’s extent at the document scale, plus margins and the title block’s band, floored and capped — and the placement of that drawing on it.
TextSize
The one size the printed title block sets everything in: the canvas’s own block-title size at the document scale, so the block reads at the size of the titles in the drawing above it.

Enums§

Fitting 🔒
How a value too wide for its column gives way.

Constants§

BLOCK_BORDER 🔒
BLOCK_PAD 🔒
Breathing room between the title block’s lines and the rule around them.
BLOCK_RADIUS 🔒
The rule’s corner radius and weight.
BLOCK_ROWS 🔒
The tallest the title block gets: its two-column head, then the path and the provenance line beneath it. What a page reserves under its drawing.
CAPTION_GAP 🔒
CLEARANCE 🔒
Clear space between the drawing and the title block beneath it, half an inch, so the block reads as the sheet’s rather than as part of the diagram.
COLUMN_GAP 🔒
The gutter between the head’s two columns, and between a caption and what it captions.
ELIDED 🔒
What stands in for the head of a path a line had no room for.
KAPPA 🔒
The circular-arc control-point ratio: a quarter circle drawn as one cubic puts its handles this fraction of the radius from the corner.
LEADING 🔒
Space between one of the block’s lines and the next.
MARGIN 🔒
Page margin, half an inch.
MAX_PAGE 🔒
The largest page dimension common readers accept (Acrobat’s 200-inch limit), in points. A scope that would overflow it is scaled down to fit — the one case where the document-wide scale gives way.
MEASURING_RUN 🔒
A run with an ascender and a descender, so the line box measured off it is the one every line of the block gets.
MIN_PAGE 🔒
The smallest sheet cut, 4×3 in: a two-block scope gets a small page, not a postage stamp under a block wider than the drawing.
SCALE 🔒
One world-unit-to-point ratio for the whole document — the CSS pt/px convention — so a block is the same physical size on every page and the pages differ instead of the scale: fitting every scope to one uniform sheet blows the small ones up and shrinks the large ones down. Mixed page sizes are ordinary PDF (readers, annotators and printers all take per-page media boxes).

Functions§

ancestor_links 🔒
A link over each ancestor segment of cell’s path, aimed at that ancestor’s page. The last segment names this page and gets none; a segment the line had no room for was dropped, and its link with it.
ancestors_of 🔒
The page of every scope order[index] hangs from, outermost first — one per ancestor segment of its path, which is what the title block’s Path row links each of its own segments to. Pre-order puts every ancestor before its descendants, so the search only ever looks backwards.
content_box 🔒
The band a sheet of size places its drawing in.
destination 🔒
The top of a page, which is where a jump to a scope should land.
draw_page 🔒
draw_title_block 🔒
The title block, in the corner an ECAD sheet keeps it, from the one definition the editor’s block is also drawn from (blockworx_editor::title_block::Grid): a two-column head over the path and whatever else runs wide, anchored to the lower-right margin from the backend’s measured widths and ruled like a sheet’s block.
export
Render scene to PDF bytes: one page per scope, outlined and cross-linked.
fill 🔒
fit_segments 🔒
The trailing run of segments that measures inside width — a path’s tail is the part that names where you are — with an ellipsis for the rest. At least one segment is always kept: a path that says nothing at all is worse than one that overruns its column.
link 🔒
A link annotation over rect jumping to the top of page.
metadata 🔒
The document information a reader shows. No creation date is written: the only clock available would make two exports of one document differ, and a byte-identical export is what the golden pins.
page_scopes
Every scope this export cuts a page for, in page order — the plan’s own answer, for the test that holds the PDF’s pages, the navigator’s branches and the canvas’s double borders to one predicate.
paint 🔒
The ink krilla draws role in — the theme’s own answer, restated in the PDF’s colour type.
plan 🔒
Walk the navigation hierarchy from the document’s designated top, numbering pages depth-first as the navigator lists them.
rounded_rect 🔒
A rounded rectangle, cornered with cubics — krilla’s path builder speaks segments, not primitives with radii.
scope_title 🔒
A scope’s heading: the block’s title, or untitled block where it has none.
shortened 🔒
text trimmed from the front until it measures inside width.