PeachPDF
PeachPDF.Layout
IDocumentBuilder Interface
Builds a declarative document page by page, for CreateDocument(Action<IDocumentBuilder>, PdfGenerateConfig)/ AddPages(PeachPdfDocument, Action<IDocumentBuilder>, PdfGenerateConfig). This builder constructs PeachPDF’s own internal box tree directly - it never generates or parses HTML/CSS text from caller content, except for an optional Stylesheet(PeachPdfCssContent) a caller attaches explicitly.
public interface IDocumentBuilder
| Methods | |
|---|---|
| OverlayFile(Action<IFileLayerDescriptor>) | Stamps pages of an existing PDF file over the document’s pages once they are drawn - a watermark, a “DRAFT” stamp, a letterhead’s foreground. May be called more than once; layers apply in the order they are added. |
| Page(Action<IPageDescriptor>) | Appends one more paginated page-section to the document. Callable more than once per document; each call’s content flows and paginates independently of the others. |
| Stylesheet(PeachPdfCssContent) | Attaches a stylesheet to this document, so a caller-defined .class/#id/compound/ descendant selector rule matches and applies against every container tagged via Class(string)/Id(string)/Tag(string) across every Page(Action<IPageDescriptor>) in this document, and any @font-face/@property/ @font-palette-values/@page at-rule it declares takes effect too. Callable anywhere in the document-building callback, before, after, or interleaved with Page(Action<IPageDescriptor>) calls - Page(Action<IPageDescriptor>) itself only records its handler; every page’s actual content tree (and this stylesheet’s effect) is built afterward, once the whole callback has finished. Calling this more than once keeps only the last stylesheet; to combine several, merge them into one PeachPdfCssContent first via its own AddStyleSheet(string). A bare type selector like div/img/a also matches this API’s own internal box structure (every anonymous container is tagged "div" by default, unless renamed via Tag(string)) - prefer class/id selectors, or Tag(string), for predictable targeting. Precedence: an explicit builder call (e.g. Padding(PdfLength), Margin(PdfLength)/Size(PageSize)) always outranks a non-!important rule in this stylesheet - the same precedence an inline style="" attribute would have over an author stylesheet - but a matching !important rule always wins, matching real CSS. A base @page rule’s geometry only fills in what a page’s own Margin(PdfLength)/Size(PageSize) call left unset, ranking between an explicit call and the document’s PdfGenerateConfig default. |
| UnderlayFile(Action<IFileLayerDescriptor>) | Stamps pages of an existing PDF file under the document’s pages, before their own content is drawn - a letterhead or a form background that the page’s content then sits on. See OverlayFile(Action<IFileLayerDescriptor>) for what is carried over. |