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
- New accounts (created after October 29, 2018) will only have the option to use Lua in scripts.
- 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.
- 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 returns the output of your pdf.
For more info on PHP PDF Creation visit: https://github.com/rospdf/pdf-php/blob/master/readme.pdf
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 portion of the script we output the formatted PDF.
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'); sgapiNewPDF(%%pdf,'letter','portrait'); sgapiSetFontPDF(%%pdf,'courier'); sgapiSetColorPDF(%%pdf,0,0,0); sgapiImagePDF(%%pdf,"https://surveygizmolibrary.s3.amazonaws.com/library/160589/surveysoftwareapi.png"); sgapiTextPDF(%%pdf,%%text,%%size,%%options); sgapiTablePDF(%%pdf,%%table,%%columns,'Table Title'); %%formattedpdf = sgapiPDFOutput(%%pdf); %%attachment['example.pdf'] = %%formattedpdf; //Attach to existing send email action (ID 3) sgapiSetQuestionProperty(3,"email_attachments",%%attachment);