
Latest Release Info
See what's new in GrapeCity Documents.
Generate PDF Reports from HTML Templates in .NET 6
Save time and avoid mistakes when using document templates. GcPDF allows you to bind HTML templates to various data sources by using report templates that generate PDF files from HTML.
- Automate and customize documents and report generation
- Fast, powerful, and comprehensive APIs
- Bind with any data source
- Compatible with the .NET Framework
- Optimized performance for server environments
Steps to Generate PDF Reports
Step 1: HTML Templates
Create HTML templates and include placeholders for data.


Step 2: Bind HTML Templates with Data
Use the Stubble.Core package and its StubbleBuilder class to bind the template. // Bind the template to data
var builder = new Stubble.Core.Builders.StubbleBuilder();
var boundTemplate = builder.Build().Render(TemplatePath, new { Query = products });
Steps to Generate PDF Reports
Step 3: Convert Bound HTML to PDF
Use GcHtmlRenderer to pass the bound HTML template and render it to PDF.using GrapeCity.Documents.Html;
// Render the bound HTML
using (var re = new GcHtmlRenderer(boundTemplate))
{
re.RenderToPdf(PdfPath};
}


Step 4: Customize a PDF
Add margins, headers, and footers to the PDF file while converting the bound HTML template using GcHtmlRenderer.

Render a report with the list of products from the standard NWind sample database using a {{mustache}} HTML template.
Read the blog Try the Demo View DocumentationGrapeCity Documents is Trusted by the World’s
Leading Companies
