Pulsar System Interaction API

Export
saveAs

The saveAs operation will allow you to generate and display a PDF or PNG image file of the currently displayed document. This is useful for exporting displayed data or saving completed forms. This request returns the file path to the resulting PDF (default) or PNG image.  In the below example we return image file path. The extension of the filename does not determine the format of the resulting file.

For Pulsar for FSL users, the "docnode" parameter (introduced in version 3.6.4 for iOS and Android and version 3.7.3 for WIndows) should be used for saving documents used as customized pages within the FSL interface. This value should be set to "window.iFrame.contentWindow.document" to ensure proper formatting of the resulting PDF.

If you'd like to add a header or footer, you should read more here.

For all platforms version 3.7.3+ the "printoptions" parameter is available, which allows specifying settings for PDF print formatting. Currently supported are options for papersize, and top, left, bottom, and right margins. See below for examples.

When the "datauri" parameter is used to save data to the filesystem, the only other parameters that apply are "filename" and "displayresult".

"format" and "imageformat" were deprecated in 12.0.

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

The print operation will allow you to print the currently displayed document using the available system printing resources. This is useful for printing displayed data or saving completed forms (for example, printing to a file, if the option is available)

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

The mail API allows you to open a pre-populated draft email composer window. The user can then make any necessary edits and send the email. The user will then be returned to the App running in Pulsar.

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));
});
    

Related pages