Rendering
The shorthand
Section titled “The shorthand”For most cases, render straight from the document:
byte[] pdf = document.RenderAsPdf();byte[] docx = document.RenderAsDocx();byte[] xlsx = document.RenderAsXlsx();byte[] html = document.RenderAsHtml();PDF accepts options as a second parameter:
byte[] pdfA3 = document.RenderAsPdf(new PdfRenderOptions { Standard = PdfStandard.PdfA3 });Internally, each RenderAsX method lays the document out (positions and sizes for every element) and then hands the result to the format-specific renderer. The layout engine and the built-in renderers are not part of the public API - RenderAsPdf/RenderAsDocx/RenderAsXlsx/RenderAsHtml are the supported way to produce output.
Custom renderers
Section titled “Custom renderers”To target a format Papyra doesn’t ship, implement IDocumentRenderer and pass it to Render. A custom renderer works directly on the Document model:
public sealed class MarkdownRenderer : IDocumentRenderer{ public byte[] Render(Document document) { // walk the document model and produce your format }}
byte[] markdown = document.Render(new MarkdownRenderer());Everything is just bytes
Section titled “Everything is just bytes”Renderers return byte[] - no files, no streams, no temp directories. Write them to disk, return them from an API controller, attach them to an email:
return File(pdf, "application/pdf", "invoice.pdf"); // ASP.NET CoreRendering is deterministic and in-process: every format, HTML included, is produced by Papyra itself with no external service, conversion step, or headless browser. (Printing an HTML file to PDF from your browser is something you may choose to do afterwards - Papyra is not involved.)
© 2026 Stefan Nikolei. Payments are processed by Paddle.com as merchant of record.