Lua Scripting Resources

Important Update to Custom Scripting

SurveyGizmo's CustomScript Action now supports the LUA programming language.


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. Read-only scripts will continue to function; you will just be prevented from editing. The exact date on this is to be determined; we will send notifications well ahead of time.


 Go to our Legacy Scripting Documentation.

While SurveyGizmo is one of the most flexible survey tools around, we get requests for customizations that are not available out of the box. This is where JavaScript and Custom Scripting can save the day. If you have scripting chops you can use the JavaScript action or the Custom Scripting action to achieve the survey of your dreams.


[article("bodfy")]

This function adds text to the given PDF. 

See this function and other PDF functions in action in an example survey.

OR

Add a survey with a script with this function and otherPDF functions to your account.

For more info on PHP PDF Creation visit: https://github.com/rospdf/pdf-php/blob/master/readme.pdf

Parameters
Description
Required
pdf
The title of the PDF you are creating.
true
textThe text to add to the PDF.
false
sizeThe font size.
false (default is 12)
optionAn array of below possible options (see below table of possible options)false
testChecks if the text is going to overflow onto a new page or not, returning true or false.false

*Provide parameters in the above order.

Possible OptionsDescriptionValues
option['left']gap to leave from the left marginnumber
option['right']gap to leave from the right marginnumber
option['aleft']absolute left position (overrides 'left')number
option['aright']absolute right position (overrides 'right')number
option['justification']
'left', 'right', 'center', 'centre', 'full'
option['leading']defines the total height taken by the line, independent of font heightnumber
option['spacing']line spacing1, 1.5, 2

Example

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 textpdf.

pdf = "Example PDF"
text = "Text to include in PDF"
size = 14
options = {['spacing'] = 1.5}
table = {row1={1,2,3,4}, row2={5,6,7,8}, row3={9,10,11,12}}
columns = {'Column A','Column B','Column C','Column D'}

newpdf(pdf,'letter','portrait')
setfontpdf(pdf,'courier')
setcolorpdf(pdf,0,1,1)
imagepdf(pdf,'https://surveygizmolibrary.s3.amazonaws.com/library/160589/surveysoftwareapi.png') 
textpdf(pdf,text,size,options)
tablepdf(pdf,table,columns,'Table Title')

formattedpdf = pdfoutput(pdf)

attachment = {}

attachment['example.pdf'] = formattedpdf

--Attach to existing send email action (ID 30)
setquestionproperty(30,"email_attachments",attachment)

See also the following working examples for use of this function: