Skip to main content

Use a Report- dlex-layout Endpoint

Use the `dlex-layout` endpoint to create PDF reports dynamically on the cloud.

After creating a DLEX report using DynamicPDF Designer, you can use the created DLEX file combined with a JSON file to generate PDF documents using an HTTP POST form request dynamically.

In this tutorial, you use the dlex-layout REST endpoint to make an HTTP request for a PDF and receive an HTTP response containing the generated PDF.

Required Resources

To complete this tutorial, if you did not add the resources in the samples folder creating-a-report-template-designer, then add them now.

  • Navigate to the File Manager and from the Samples dialog, add the creating-a-report-template-designer folder to add the sample resources.

Figure 1. The Create a Report (Designer Tutorial) sample project.

  • Download invoice.json to your local system,
  • Rename the downloaded file to invoice-local.json; here we assume the local folder /temp/dynamicpdf-api-samples/using-dlex-layout.

You should have invoice.dlex and invoice.json in your cloud storage space and invoice-local.json in your local filesystem. Now that we have our resources, let's use review the existing DLEX report.

Test DLEX on Cloud

Typically, when using the dlex-layout endpoint you would first create the DLEX on the cloud using DynamicPDF Designer and simultaneously test your JSON dataset while developing. This is the strategy we employed when we completed the tutorial Create a Page Using a Template. However, after debugging the DLEX file, you should then use layout data that resides in your local system rather than on the cloud. We will demonstrate this difference by using invoice-local.json from your local file system rather than invoice.json. But first, let's run the report in Designer.


Remember, layout data is your organization's data, keep this data safe by never storing it in the cloud - unless the data is sample data

  • In the Portal, open the File Manager, and open the folder creating-a-report-template-designer.
  • Double-click on invoice.dlex to open the DLEX in Designer.
  • Run the report by clicking the Run Report (the green arrow) button.

Figure 2. Double-click on a DLEX file to open it in DynamicPDF Designer.

  • After closing the generated report, exit the Portal.

Note that if the DLEX file and the JSON file have the same name and are in the same folder, then Designer will attempt to load the data automatically.

Now that we have ensured the DLEX file generates a PDF, let's use the dlex-layout endpoint to generate the PDF report.

dlex-layout Endpoint

The dlex-layout endpoint takes a POST request containing the path to the DLEX file and the JSON data. The endpoint then generates a PDF document and is returned as an HTTP response to your calling application.

The following summarizes the HTTP POST request and the resulting response's content-type. Note that if you use one of the client libraries, then these REST call details are handled for you by the API.

Request Body FieldsDlexPath
Request File FieldLayoutData
Header FieldAuthorization

Calling Endpoint

You can call the endpoint directly or use one of DynamicPDF's client libraries. Let's illustrate calling the pdf-dlex endpoint using Postman, cURL, and then by using the Java, C#, Node.js, and PHP client libraries.

Access the complete source for this project at one of the following GitHub projects.

LanguageFile NameLocation (package/namespace/etc.)GitHub Project

Select the tab of the desired language to view the tutorial steps for that particular language. Refer to Creating a PDF (dlex-layout) tutorial for detailed instructions on using one of the client libraries with the dlex-layout endpoint.


Available on NuGet:

Install-Package DynamicPDF.API
  • Create a new Console App (.NET Core) project named DesignerReportTemplate.
  • Add the DynamicPDF.API NuGet package to the project.
  • Create a new method named Run that takes the api key and the basepath as parameters.
  • In the Run method, create a new LayoutDataResource instance that points to the local layout data.
  • Create a new DlexLayout instance and pass the path to the DLEX file in cloud storage and the newly created LayoutDataResource instance.
  • Set the endpoint's api key and then add the call to the endpoint's process method.
  • Obtain the results as a PDFResponse and if it is successful, save the results as a PDF.
using DynamicPDF.Api;
using System;
using System.IO;

namespace DesignerReportTemplate
class Program
static void Main(string[] args)
Run("DP. API-KEY", "C:/temp/dynamicpdf-api-samples/using-dlex-layout/");

public static void Run(String apiKey, String basePath)
LayoutDataResource layoutData = new LayoutDataResource(basePath + "invoice-local.json");
DlexLayout dlexEndpoint = new DlexLayout("samples/creating-a-report-template-designer/invoice.dlex", layoutData);
dlexEndpoint.ApiKey = apiKey;
PdfResponse response = dlexEndpoint.Process();

if (response.IsSuccessful)
File.WriteAllBytes(basePath + "invoice-csharp-output.pdf", response.Content);


This tutorial illustrated how to use a DLEX file created using DynamicPDF Designer to call the dlex-layout REST endpoint. In all four languages, the steps were similar. First, we created a new LayoutData instance by loading the path to the JSON via the constructor. In the constructor, we passed the path to the DLEX file on the File Manager and the LayoutData instance. Next, we created a new instance of the DlexLayout class, which abstracts the dlex-layout endpoint. The DlexLayout instance saves the results as a PDF after processing if the processing was successful. Finally, we called the Process method and saved the resultant PDF.