Pulsar System Interaction API
Export
saveAs
var request = { "type" : "saveAs", "data" : { "filename" : "demo.png", // required -- the filename of the created file "displayresult" : 0, // optional -- this is a number, positive to display the file, 0 to simply return data, default is 0 "datauri" : "data:image/jpeg;base64,/9j/4AA...", // optional -- this is a well-formed data URI containing data you wish to save to a file. None of the parameters below will take effect if this option is used. "format" : "image", // [DEPRECATED in v12.0] optional -- this is a string, either "image" or "pdf"-- default is "pdf" "imageformat" : "png", // [DEPRECATED in v12.0] optional -- this is a string, either "png" or "jpg" -- default is "png" "papersize" : "letter", // optional, can also be specified in printoptions -- this is a string, valid values: "letter", "a4", "legal" -- default is "letter" or "a4" based on your device settings "docnode" : "window.document", // optional (iOS, Android version 3.6.4+, Windows version 3.7.3+) -- this is a string, representing the html document node Pulsar will use to generate a PDF. For example, for a document in an iFrame, "window.frames[0].contentWindow.document". default is "window.document" "headernode" : "document.getElementById('my-header')", // defines the section of the current document that will be used by iOS and UWP as the repeating page header -- you must specify a header height in the printoptions below. SEE ABOVE FOR MORE DOCUMENTATION "footernode" : "document.getElementById('my-footer')", // defines the section of the current document that will be user by iOS and UWP as the repeating page header -- you must specify a footer height in the printoptions below. SEE ABOVE FOR MORE DOCUMENTATION "printoptions" : { // (All platforms, version 3.7.3+) supports the following optional options in any combination "topmargin": 28, // all margins specified in points-- 72 points per inch, 2.83465 points per mm "leftmargin": 28, "bottommargin": 28, "rightmargin": 28, "papersize": "a4", // overrides top-level papersize parameter, if specified "headerheight": 88, // optional, but necessary if you are supplying a header (also in points) SEE ABOVE FOR MORE DOCUMENTATION "footerheight": 40, // optional, but necessary if you are supplying a footer (also in points) SEE ABOVE FOR MORE DOCUMENTATION }, } }; bridge.sendRequest(request, function (results) { console.log('Javascript got its response: ' + JSON.stringify(results)); if (results.type === "saveasResponse") { var imageFilePath = results.data.FilePath; // the resulting contains the file path to the file //do something with the data } else if (results.type == 'error') { errStr = results.data; alert('A problem occurred:\n' + errStr); } });
print
var request = { "type" : "print", "data" : { // data is empty } }; bridge.sendRequest(request, function (results) { console.log('Javascript got its response: ' + JSON.stringify(results)); if (results.type === "printResponse") { // success case } else if (results.type == 'error') { errStr = results.data; alert('A problem occurred:\n' + errStr); } });
Communication
mail
var request = { "type" : "mail", "data" : { "to" : [ "list_of@emails.com" ], // array of emails, optional "cc" : [ "list_of_cc@emails.com" ], // array of emails, optional "attach" : [ "/list/of/file/paths" ], // array of file paths to attach, optional "subject": "subject of this email", // email subject text, optional "body" : "body of the email ", // body text, optional } } bridge.sendRequest(request, function (results) { console.log('Javascript got its response: ' + JSON.stringify(results)); });