sgapiTablePDF(%%pdf, %%data, %%cols, %%title, %%options)

Important Update to Custom Scripting

SurveyGizmo's CustomScript Action now supports the LUA programming language. Visit our NEW Lua Scripting Resources!

Legacy Custom Scripting Language Deprecation Plans 

  1. New accounts (created after October 29, 2018) will only have the option to use Lua in scripts.
  2. As of October 29, 2018 Custom Scripting Actions will default to Lua as the scripting type in the Custom Scripting Action for accounts created before this date. You will be able to switch to the Legacy Custom Scripting; though we highly encourage using Lua.
  3. In the long term, Legacy Custom Scripting Actions will be switched to read-only. The exact date on this is to be determined; we will send notifications well ahead of time.

This function adds a table to the given PDF.


  • %%pdf - The title of the PDF you are creating.
  • %%data = array() - The array of data to include in the table.
  • %%cols= array() - The array of column headers.
  • %%title - The table title.
  • %%options = array () - See PHP PDF Creation documentation for options.

For more info on PHP PDF Creation visit:


The below script creates and builds a PDF object, outputs it and adds it as an attachment to a send email action. In the highlighted portions of the script we the table data and columns and add it to the PDF using sgapiTablePDF.

Check it out in an example survey


Download a survey with these scripting functions to your account

%%pdf = "Example PDF";
%%text = "Text to include in PDF";
%%size = 14;
%%options = array('spacing' => 1.5);
%%table = array( array(1,2,3,4), array(5,6,7,8), array (9,10,11,12) );
%%columns = array('Column A','Column B','Column C','Column D');

sgapiTablePDF(%%pdf,%%table,%%columns,'Table Title');

%%formattedpdf = sgapiPDFOutput(%%pdf);

%%attachment['example.pdf'] = %%formattedpdf;

//Attach to existing send email action (ID 3)