sgapiTextPDF(%%pdf, %%text, %%size, %%options, %%test)

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 text to the given PDF.


  • %%pdf - The title of the PDF you are creating.
  • %%text - The text to add to the PDF.
  • %%size - The font size (default is 12 ).
  • %%option = array () -
    • 'left' => number - gap to leave from the left margin
    • 'right' => number - gap to leave from the right margin
    • 'aleft' => number - absolute left position (overrides 'left')
    • 'aright' => number - absolute right position (overrides 'right')
    • 'justification' => 'left', 'right', 'center', 'centre', 'full'
    • 'leading' => number - defines the total height taken by the line, independing of font height
    • 'spacing' => 1, 1.5, 2 - line spacing
  • %%test - Checks if the text is going to flow onto a new page or not, returning true or false.

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 below script we define the text  to include in the PDF as well as the options and the font size and add the formatted text to the PDF via sgapiTextPDF.

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)