Extends NativeObject

Allows to print PDF documents or images from the device. A printer object is always available from tabris.printer.

Import this object with “const {printer} = require('tabris');


print(data, options)



  • data: any
    • the bytes of the document to print. The value can either be an ArrayBuffer or a typed array containing the bytes of a PDF document or image.
  • options: {jobName?: string, contentType?: string} [Optional]
    • an optional set of configuration parameters. Setting the jobName allows to provide the document name shown the user. The contentType is required when printing a specific document format. By default application/pdf is used but it needs to be changed to image/* when printing an image

Returns: *Promise*

Prints a PDF document using the native printing capabilities of the device. The data has to be provided as an ArrayBuffer or typed array. The method returns a promise which resolves to an event object with the property result. The result can either be completed or canceled. When printing fails the promise is rejected with an Error parameter containing additional information about the error. Supported on iOS and Android 4.4+.


const {Button, printer, ui, app} = require('tabris');

// Print a bundled PDF

new Button({
  left: 16, right: 16, top: 16,
  text: 'Print PDF'
}).on('select', () => print('resources/example.pdf', 'application/pdf', 'Example PDF'))

new Button({
  left: 16, right: 16, top: 'prev() 16',
  text: 'Print Image'
}).on('select', () => print('resources/salad.jpg', 'image/jpg', 'Salad image'))

function print(file, contentType, jobName) {
    .then(res => res.arrayBuffer())
    .then(data => printer.print(data, {jobName: jobName, contentType: contentType}))
    .then(event => console.log('Printing finished', event))
    .catch(err => console.error(err));

See also