sgapiHTMLTOPDF(%%contents, %%landscape, %%border)

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.

Converts the HTML provided in %%contents to a PDF file.

%%landscape and %%borders parameters are boolean values and are optional.

By default, the %%border parameter is true, and the %%landscape parameter is false. The %%border parameter will add print margins to your PDF (white space around the content). To allow your content to take up the full width and height of your PDF page, set the %%border parameter to false.


In this example, we create a PDF file from the contents of a question on the survey, and then email the pdf as an attachment to the survey administrator.

%%contents = sgapiGetValue(2);
%%pdf = sgapiHTMLTOPDF(%%contents);

%%attachment['filename.pdf'] = %%pdf;

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