PeachPDF

PeachPDF.Layout

IContainer Interface

One composable content box in a declarative document - reused everywhere content is placed (a page’s content area, a column/row item, a table cell). Every decorator method wraps the current box in one more layer and returns the new, innermost IContainer; every terminal method places real content and may be called at most once per container.

public interface IContainer
Methods  
AlignCenter() Center-aligns this container’s own content horizontally. On a table cell this centers the cell’s text; anywhere else it centers the container within its parent.
AlignLeft() Left-aligns this container’s own content. On a table cell (Cell(int, int)), whose margins cannot position it, this aligns the cell’s text; anywhere else it positions the container within its parent.
AlignRight() Right-aligns this container’s own content. On a table cell this right-aligns the cell’s text - the way to right-align a column of amounts; anywhere else it pushes the container to the right of its parent.
Background(PdfColor) Paints a solid background color behind this container’s own box.
BackgroundLinearGradient(double, PdfColor[]) Sets a background linear gradient (angle in degrees, clockwise from the top), with 2 or more evenly-spaced color stops.
BeginPageNumberOfSection(string) Tags this container’s own physical position as the start of a page-numbered section named sectionId, anywhere in a page’s normal content flow (not just Header(Action<IContainer>)/Footer(Action<IContainer>) content) - a decorator, like Bookmark(string, int), so chain it before the container’s own terminal content (column.Item().BeginPageNumberOfSection("chapter1").Text("Chapter 1")) rather than giving the section boundary a container of its own. Pair with a later EndPageNumberOfSection(string) call using the same id, on whichever container holds the section’s own last piece of content; PageNumberWithinSection(string)/ TotalPagesWithinSection(string) then resolve against the physical pages that pair of tagged containers land on.
Bookmark(string, int) Adds a PDF outline (bookmark) entry pointing at this container, titled title at nesting level (1 = top level).
Border(PdfLength, Nullable<PdfColor>) Draws a solid border of width/color (default black) on all four sides.
BorderBottom(PdfLength, Nullable<PdfColor>) Draws a solid border on the bottom side.
BorderColor(PdfColor) Sets every already-declared border edge’s color.
BorderHorizontal(PdfLength, Nullable<PdfColor>) Draws a solid border on the left and right sides.
BorderLeft(PdfLength, Nullable<PdfColor>) Draws a solid border on the left side.
BorderLinearGradient(PdfLength, double, PdfColor[]) Draws a linear-gradient border (angle in degrees, clockwise from the top) of width, with 2 or more evenly-spaced color stops, on all four sides.
BorderRight(PdfLength, Nullable<PdfColor>) Draws a solid border on the right side.
BorderTop(PdfLength, Nullable<PdfColor>) Draws a solid border on the top side.
BorderVertical(PdfLength, Nullable<PdfColor>) Draws a solid border on the top and bottom sides.
ClampLines(int, string) Truncates this container’s own text after lines lines, marking the cut with an ellipsis (overflow: hidden + line-clamp). Applies only when this container’s own terminal content is text. By default the cut is marked with the usual “…”; pass ellipsis for a custom marker instead (e.g. " [more]"), or "" for no marker at all - the text is still cut at lines lines, just with nothing appended (block-ellipsis: none).
Class(string) Tags this container with a CSS class name, so a stylesheet attached via Stylesheet(PeachPdfCssContent) can target it with a .className selector (including compound/descendant selectors built from it). Purely inert metadata with no visual effect when no stylesheet is attached - safe to call as a stable hook even if styling is added later. Calling this more than once on the same container adds an additional class (space-separated), matching HTML’s own multi-valued class attribute, rather than replacing the previous one.
Column(Action<IColumnDescriptor>) Places a vertical column of items. Terminal - may be called at most once.
CornerRadius(PdfLength) Rounds all four corners by the same radius.
CornerRadiusBottomLeft(PdfLength) Rounds the bottom-left corner.
CornerRadiusBottomRight(PdfLength) Rounds the bottom-right corner.
CornerRadiusTopLeft(PdfLength) Rounds the top-left corner.
CornerRadiusTopRight(PdfLength) Rounds the top-right corner.
DefaultTextStyle(Action<ITextStyle>) Sets the default text style every span of text inside this container inherits unless it overrides a property itself.
EndPageNumberOfSection(string) Tags this container’s own physical position as the end of the page-numbered section sectionId - see BeginPageNumberOfSection(string).
Grow(double) Inside a IColumnDescriptor/IRowDescriptor item, lets this item grow to fill available space (flex-grow).
Height(PdfLength) Sets an explicit height.
Html(byte[], PeachPdfCssContent, Action<SlotContext,IContainer>) Places an HTML fragment loaded from raw bytes - see Html(string, PeachPdfCssContent, Action<SlotContext,IContainer>). Terminal - may be called at most once.
Html(string, PeachPdfCssContent, Action<SlotContext,IContainer>) Parses html as an HTML fragment (through the same HTML parser and cascade the HTML-string rendering path uses) and splices the result into this container’s tree, in place, as one new child holding the fragment’s own top-level nodes (which may be more than one - unlike every other terminal method here, an HTML fragment can itself contain several sibling elements). Terminal - may be called at most once. stylesheet supplies the CSS the fragment’s own class/id-driven styling cascades against, layered under the fragment’s own <style> tags and the user-agent defaults every HTML element already gets; null styles the fragment with only those two. A <link rel="stylesheet"> inside the fragment is never loaded (there is no document context to resolve it through at this point in building the tree) - author it as a <style> tag, or pass it via stylesheet, instead. A float: footnote element inside the fragment renders as ordinary inline content rather than being detached into a footnote area, for the same reason. onSlot, when given, is invoked once per <slot> element the fragment contains (in document order, regardless of name, including more than one sharing a name), with a SlotContext describing it and an IContainer positioned to replace it - populate that container the same way any other container is populated (e.g. slotContainer.Text(...)) to fill the slot. Leaving it untouched (or passing no onSlot at all) keeps the slot’s own fallback content - whatever markup it contained in html - exactly as authored.
Html(Stream, PeachPdfCssContent, Action<SlotContext,IContainer>) Places an HTML fragment read fully from a stream - see Html(string, PeachPdfCssContent, Action<SlotContext,IContainer>). Terminal - may be called at most once.
Hyperlink(string) Wraps this container in a hyperlink to url.
Hyperlink(Uri) Wraps this container in a hyperlink to url. An internal document anchor (a #fragment-only URI) is not yet supported by this overload - use the string overload with a full external URL.
Id(string) Tags this container with a CSS id, so a stylesheet attached via Stylesheet(PeachPdfCssContent) can target it with a #id selector. Purely inert metadata with no visual effect when no stylesheet is attached. Calling this more than once on the same container replaces the previous id (an element has at most one id) - unlike Class(string), this does not accumulate.
Image(byte[]) Places an image loaded from raw bytes. Terminal - may be called at most once.
Image(PdfImage) Places a reusable PdfImage - pass the same instance to more than one container to place it in multiple places without reloading/redecoding its source. Works for a shared SVG source too - PdfImage detects the format automatically, same as the other overloads. Terminal - may be called at most once.
Image(string) Places an image loaded from a local file path. Terminal - may be called at most once.
Image(Func<PdfSize,byte[]>) Places an image generated on demand, at exactly this container’s own resolved size, once that size is known - generator receives it as a PdfSize. Requires this container to have (or inherit, via the default width:100%;height:100% this fills with) a definite size: an explicit Width(PdfLength)/Height(PdfLength) on it, or an ancestor that already has one - a container with no definite size anywhere in its ancestry throws System.InvalidOperationException once layout reaches it. Useful for a chart or other generated graphic that should render at its actual placed resolution rather than a guessed fixed one (mirrors QuestPDF’s own dynamic-image API). Terminal - may be called at most once.
Image(Stream) Places an image read fully from a stream. Terminal - may be called at most once.
Image(Uri) Places an image loaded over the network. Terminal - may be called at most once.
LineHorizontal(PdfLength, Nullable<PdfColor>, bool) Places a horizontal rule of the given thickness, filled with color (default black), or dashed when dashed is true. Terminal - may be called at most once.
LineVertical(PdfLength, Nullable<PdfColor>, bool) Places a vertical rule of the given thickness, filled with color (default black), or dashed when dashed is true. Terminal - may be called at most once.
OrderedList(Action<IListDescriptor>, PdfListMarkerType) Places a numbered list. Terminal - may be called at most once.
Padding(PdfLength) Sets padding on all four sides.
PaddingBottom(PdfLength) Sets bottom padding.
PaddingHorizontal(PdfLength) Sets left and right padding.
PaddingLeft(PdfLength) Sets left padding.
PaddingRight(PdfLength) Sets right padding.
PaddingTop(PdfLength) Sets top padding.
PaddingVertical(PdfLength) Sets top and bottom padding.
PageName(string) Tags this container’s own position as the start of the named page type name (CSS page property, [CSS
2.1 §13.2](https://www.w3.org/TR/CSS21/page.html#page-selectors ‘https://www.w3.org/TR/CSS21/page.html#page-selectors’)) - combine with a document-level stylesheet’s own @page name { ... } rule (see Stylesheet(PeachPdfCssContent)) to switch page size/margins/orientation from this point in the flow onward, forcing a page break if a different named page (or no named page) was active immediately before. A decorator, like Bookmark(string, int)/ BeginPageNumberOfSection(string) - chain it before the container’s own terminal content.  
ParagraphFirstLineIndentation(PdfLength) Indents this container’s first line (text-indent). Applies only when this container’s own terminal content is text.
ParagraphSpacing(PdfLength) Adds space after this container (margin-bottom) - a convenience for spacing paragraphs apart.
Row(Action<IRowDescriptor>) Places a horizontal row of items. Terminal - may be called at most once.
Shadow(PdfBoxShadow[]) Adds one or more drop shadows behind this container’s own box.
Svg(byte[]) Places inline SVG markup loaded from raw bytes. Terminal - may be called at most once.
Svg(string) Places inline SVG markup. Terminal - may be called at most once.
Svg(Func<PdfSize,string>) Places SVG markup generated on demand, at exactly this container’s own resolved size, once that size is known - see Image(Func<PdfSize,byte[]>)’s own doc comment for the size-resolution rules, which are identical here. Terminal - may be called at most once.
Svg(Stream) Places inline SVG markup read fully from a stream. Terminal - may be called at most once.
Table(Action<ITableDescriptor>) Places a table. Terminal - may be called at most once.
Tag(string) Renames this container’s own internal tag name (a synthetic "div"/"img"/"a" by default, depending on which method created it) to tagName, so a stylesheet attached via Stylesheet(PeachPdfCssContent) can target it with a bare type selector (e.g. li { ... }) matching the intended semantic element rather than the internal default. Purely inert metadata with no visual effect when no stylesheet is attached.
Text(string) Places a paragraph of plain text. Terminal - may be called at most once.
Text(Action<ITextSpanContainer>) Places a paragraph of richly-styled text spans. Terminal - may be called at most once.
UnorderedList(Action<IListDescriptor>, PdfListMarkerType) Places a bulleted list. Terminal - may be called at most once.
Width(PdfLength) Sets an explicit width.