Skip to main content

Create an Invoice


Create an invoice using the DynamicPDF Designer.

In this sample you create a traditional invoice using a template. The produced PDF is a multiple page invoice.

Sample Project

The traditional-invoice project is available from the DynamicPDF Portal Samples in the File Manager.

The project consists of the following three files.

  • invoice.dlex
  • invoice.json
  • invoice-template.pdf

info

Refer to the following for more information on the File Manager and on adding sample projects.

Sample Description

The sample consists of a Report containing a Header, Footer, Conditional Footer, and Body.

The report's JSON data is top-level information related to the order followed by an array containing each order's details.

{
"OrderID": 11077,
"OrderDate": "2019-01-06T00:00:00",
"CustomerID": "RATTC",
"ShippedDate": "2019-01-30T00:00:00",
"ShipperName": "United Package",
"ShipTo": "Rattlesnake Canyon Grocery\n2817 Milton Dr.\nAlbuquerque, NM 87110\nUSA",
"BillTo": "Rattlesnake Canyon Grocery\n2817 Milton Dr.\nAlbuquerque, NM 87110\nUSA",
"Freight": 8.53,
"OrderDetails": [
{
"ProductID": 2,
"Quantity": 24,
"ProductName": "Chang",
"UnitPrice": 19
},
{
"ProductID": 3,
"Quantity": 4,
"ProductName": "Aniseed Syrup",
"UnitPrice": 10
},
{
"ProductID": 4,
"Quantity": 1,
"ProductName": "Chef Anton\u0027s Cajun Seasoning",
"UnitPrice": 22
},
{
"ProductID": 6,
"Quantity": 1,
"ProductName": "Grandma\u0027s Boysenberry Spread",
"UnitPrice": 25
},
--- snip ---

The JSON data loaded into Designer appears as follows in the Data Explorer.

The report uses a pre-existing template, report-template.pdf.

The different sections of the report are resized to the relevant portions of the template.

The report's structure appears as follows. Notice there is a footer and a conditional footer.

The conditional footer displays a sub total, freight charge, and a total.

Notice the sub total sums the UnitPrice multiplied by the Quantity, Sum(Multiply(UnitPrice,Quantity)).

While the total adds the sum and freight, Add(Freight,Sum(Multiply(UnitPrice,Quantity))).

The finished invoice is two pages and only displays the summary data on the final page.

More Information

For more information on using Designer refer to one of our many tutorials and the Users Guide documentation. Also refer to the Designer Examples documentation page in the Users Guide for numerous examples illustrating Designer's capabilities. Our blog also has numerous tips and tricks for using Designer.

   Follow us on social media for latest news!