Building Dynamic Reports with PDF-Writer.NET in ASP.NET Core
Overview
PDF-Writer.NET (DynamicPDF/Core Suite) lets you create template-driven PDF reports in ASP.NET Core by combining a designer-created DLEX template with JSON or programmatic data to produce Document objects you can stream to clients or save.
Key components
- DynamicPDF Designer — visual report template (DLEX) authoring (online).
- DocumentLayout — loads DLEX and applies data.
- Layout data types — JSON, NameValueLayoutData, or business objects.
- Document — result object you call Draw or stream to HTTP response.
Typical flow (code sketch)
- Install package (NuGet): ceTe.DynamicPDF.CoreSuite.NET
- Create DLEX template in Designer and export to your project.
- Load template and provide data:
csharp
var layout = new DocumentLayout(“Templates/MyReport.dlex”); var layoutData = new NameValueLayoutData(); layoutData.Add(“ReportTitle”, “Sales Report”); layoutData.Add(“Items”, jsonArrayOrObject); var document = layout.Layout(layoutData); var pdfBytes = document.Draw(); return File(pdfBytes, “application/pdf”, “report.pdf”);
- For web APIs, return byte[] as FileResult or stream to Response.Body for large reports.
Dynamic features to use
- Data-driven repeating sections (tables/lists)
- Conditional regions and formatting in Designer
- Charts and barcodes (Enterprise features)
- Header/footer templates and pagination
- Output to Stream, File, or direct web response
Deployment notes
- Prefer streaming for large reports to avoid memory pressure.
- License and server/processor considerations — verify server licensing for production.
- Test fonts and encodings (embed fonts if needed).
When to choose this approach
- You need designer-built, repeatable report templates with runtime data binding.
- You prefer producing native PDFs (not HTML-to-PDF) with tight control over layout.
If you want, I can provide a complete minimal ASP.NET Core controller example that returns a DLEX-based PDF (assume sensible defaults).
Leave a Reply