Created on 22 October 2021
icon_unfollowing
Login to follow
mobile-print-plugin

Mobile Print Plugin

Stable version 1.0.0 (Compatible with OutSystems 11)
Uploaded on 22 October 2021 by 
mobile-print-plugin

Mobile Print Plugin

Documentation
1.0.0

This plugin allows Android and iOS mobile applications to leverage the underlying Operating System's print capabilities. To use it, reference its client actions and call them from the consuming application.

AVAILABLE ACTIONS

PrintBase64

Prints the specified base64 encoded content. This action can be used, for instance, to print images. In order to do that, the image content must first be converted to a base64 encoded string. The Demo app contains an example of how to achieve that using a local image and the following JavaScript code:

//Get a reference to the img element.
var img = document.getElementById($parameters.ImageId);

//Add a canvas element to the document, which will be used
//to get the image's content as a base64 string.
var canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;

//Draw the image in the canvas.
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0);

//Get the image content as a base64 string.
var dataURL = canvas.toDataURL("image/png");
$parameters.Base64 = "base64://" + dataURL.replace(/^data:image\/(png|jpg);base64,/, "");


PrintCurrentScreen

Prints the application's current screen with all its contents.


PrintFile

Prints the file identified by the supplied URI. The Demo app contains an example of how to do this by first saving a PDF file (stored as a Resource) to the device using the FilePlugin's SaveTemporaryFile action, and then passing the resulting URI to the print action.


PrintText

Prints the specified text content, which can also include HTML and CSS. For instance, the following text content can be used to print a document with bold and red text:

<style>
    p {
        color: red;
    }
</style>
<p>
    Sample text
</p>



CUSTOM OPTIONS

All actions have an "Options" input parameter. This is a JavasScript object that allows the consumer to specify formatting and other print parameters. The supported options vary according to the underlying Operating System, and a full list of the existing options for each platform is available at https://github.com/katzer/cordova-plugin-printer#formatting.

As an example, the following code can be used in a JavaScript node to print text with a font size of 72:

$parameters.Options = { font: { size: 72 }};

The JavaScript node's "Options" output parameter would then be passed to the print action's "Options" input parameter:



Support options
This asset is not supported by OutSystems. You may use the discussion forums to leave suggestions or obtain best-effort support from the community, including from  who created this asset.
Dependencies
See all 1 dependencies