PeachPDF

PeachPDF

PdfLength Struct

A CSS length or percentage for the declarative document-building API (CreateDocument(Action<IDocumentBuilder>, PdfGenerateConfig)) - every size-shaped parameter there (page size, margins, padding, border width, spacing, column widths, font size) is a PdfLength rather than a raw System.Double. Internally this formats to a canonical CSS length token (e.g. "12pt", "1.5in", "50%") and is resolved by PeachPDF’s own existing CSS length-parsing machinery at layout time - this is not a new, independent unit-conversion implementation.

public readonly struct PdfLength
Constructors  
PdfLength(double, PdfLengthUnit) Creates a length of valueunits (points, if omitted).
Properties  
Unit The unit Value is expressed in.
Value The numeric magnitude, in Unit.
Zero Zero points - the same as default(PdfLength), spelled out for readability at call sites.
Methods  
Centimeters(double) A length in centimeters.
Em(double) A length relative to the current element’s own font size.
Inches(double) A length in inches.
Millimeters(double) A length in millimeters.
Percent(double) A percentage of whatever basis the property being set resolves percentages against.
Picas(double) A length in picas (1pc = 12pt).
Pixels(double) A length in CSS pixels (1px = 1/96in = 0.75pt).
Points(double) A length in points (1/72 inch).
Rem(double) A length relative to the document root’s font size.
ToString() Returns the canonical CSS length token this value represents (e.g. "12pt").
Operators  
implicit operator PdfLength(double) An unsuffixed number defaults to points, matching this API’s existing call-site convention (e.g. container.Padding(10)).
implicit operator PdfLength(int) See the System.Double overload.