The most crucial portion for the HTML template is the portion that includes placeholders for data.
To understand better, let's see how to create an HTML template for our use case: generating a product price list.
The syntax used in the system is straightforward, requiring no complicated logic for getting object values.
Creating HTML Template for GcPdfĪny HTML can be a valid HTML template for GcPdf if it follows the Mustache template system. Let’s familiarize ourselves with creating valid HTML templates. This all depends on the precise formatting of our HTML templates. If the template is formatted incorrectly, the data will not show correctly. When generating any report, the HTML template creation is crucial, and the product price list is no exception.
Once you design the HTML template, apply simple C#.NET code to bind the template with the database, and GcPdf will quickly generate a separate PDF report and listing pricing for the products.īelow you can see how the final product PDF price list (in a PDF report) would look:
It can be difficult for a corporation to track and update product prices and lists continuously, this is where dynamic report generation helps. However, product prices can fluctuate, new products can be added, and existing products can fall out of stock. Use Cases – Dynamically Generating a Product Price ListĪ corporation wants to prepare the price list for all the products sold by an outlet. Now that we understand how the dynamic report generation process works let’s take a look at a real scenario. This HTML is converted to a final PDF report through ‘GcHtmlRenderer’ class in the GcPdf C#.NET API. Step 3:Ĭompletion of step 2 outputs a bound HTML. This is done through ‘Stubble.Core’ package. Once the template is ready and data is accessed, bind the template to the accessed data. The data obtained will be used to bind the HTML template created above. We can use data from various data sources like DataTable etc. This HTML template defines the layout on which the final PDF report is rendered. To generate data-bound PDF reports dynamically, GcPdf requires an HTML template. The first step covers the following two sub-steps: A.) Creating an HTML Template How Does Templating Work?ĭata bound PDF report generation is a 3-step process. Here, we'll learn how to create a valid HTML template, collect data, and make PDF documents based on the HTML template. This article demonstrates how to generate data-bound PDF files using C#. Using this syntax allows binding data fields to the database and shows the data value in these placeholders. While HyperText Markup Language (HTML) is a standard markup language for pages designed to display in a web browser, HTML templates also define placeholders for containing upcoming data fields using syntax. In this article, we'll describe how to generate PDF reports from HTML templates.īefore digging deeper into the implementation, let’s first understand how HTML templates differ from standard HTML files. Excel templates offer the ability to create dynamic Excel & PDF reports. In the previous release, GcExcel introduced Excel templates. Generating documents through a template saves not only time but also avoids possible errors. In the GrapeCity Documents V4.1 release, we have a new Documents for PDF (GcPdf) enhancement allowing users to generate data-bound PDF reports through an HTML template.