Start a conversation

ReportPDF with TCPDF library

Is using TCPDF to generate PDF files. Started in 2002, TCPDF is now one of the most active open source projects in the world, used daily by millions of users and included in thousands of CMS and web applications.

More information: clicking here

Primarily for this example, we will create a grid with a run button to execute the PDF according to the chosen products.
Read more about the run button clicking here.

In the grid, the event OnScriptInit will put the following code:

[i] = 0;
[total_chked] = array();
[i1] = 0;
[total_chked1] = array();

After this, we will use a Run button labeled "PDF Generation".
In the event OnRecord of the run button will put the following code:

$arr1 = [i1];

And in the OnFinish event, put the code below:

$tot = count([total_chked]);
$tot1 = count([total_chked1]);

$value = "";
$productname = "";

 $value += [total_chked][$x];
    $values .= [total_chked][$x];
    if($x == ($tot-1)){
    $values .= ".";
   } else {  
    $values .= ",";

     $productname .= [total_chked1][$x];
        if($x == ($tot-1)){
    $productname .= ".";
   } else {  
    $productname .= ",";

[value] = $value;
[values] = $values;
[qtd] = $tot;
[description] = $productname;

Remember to set the global variables to "Output" in "Application> Global Variables".
The application name of ReportPDF must be placed in the macro sc_redir.

Now we create an application ReportPDF.
We will place your name as "pdfreport_orders".

In the event OnScriptInit should put the code below:


We are retrieving the values passed to the grid reportPDF.

And in "LayoutPDF > Code" option, we can use the "TCPDF" class to customize our pdf:

To view the code placed in reportPDF click here.


After clicking the Run button:

Choose files or drag and drop files
Was this article helpful?
  1. Ronyan Alves

  2. Posted
  3. Updated