Presto 3 Print Provider Guide
A guide to augmenting built-in Presto support for print providers.
Table of Contents Overview Integrating a Print Provider Looking Up Printers Submit a Print Job Cancel a Print Job |
Overview
The Presto system allows administrators to plug in custom print providers to augment Presto's built-in support for discovering and printing to your system's print queues. This facility also allows system administrators to advertise virtual print queues to Presto Users.
Presto print provider plugins run as scripts or programs that output their results to stdout
as JSON formatted text.
Integrating a Print Provider
To integrate an additional print provider into the Presto system, follow these steps:
- Edit the
agent.conf
file, found in the following location: - Add a new custom print provider section by pasting in the following text. After editing the
agent.conf
file and saving the changes to it, the Presto service will automatically re-read the file and add the new print provider to the Presto system. - Create a script, with a path and file name matching that of
c:\provider.js
in theagent.conf
file, that can be passed the following commands:lookup_printers
- to discover available printersstart_job
- to submit a print jobcancel_job
- to cancel a print job
Windows
c:\ProgramData\collobos\presto\etc\agent.conf
Mac
/Library/Application Support/Collobos/Presto/etc/agent.conf
Linux
/etc/collobos/presto/agent.conf
This file is formatted as JSON text. It describes additional configuration that the Presto service will use to manage users and discover services on the network.
{ "plugins": { "print": [ { "name": “Example Print Provider", "lookup_printers": { "path": "C:\Program Files\nodejs\node", "args": [ “C:\provider.js”, "--lookup-printers" ] }, "start_job": { "path": “C:\Program Files\nodejs\node”, "args": [ “C:\provider.js”, "--start-job" ] }, "cancel_job": { "path": "C:\Program Files\nodejs\node", "args": [ “C:\provider.js”, "--cancel-job" ] } } ] }
A sample script for a print provider plugin can be found here.
Looking up Printers
Input
The lookup_printers
command is passed no parameters
Output
The output of the lookup_printers
command must be JSON formatted text. In this example, the plugin will send the following output to stdout
and return a 0 exit code.
{ "bpp": 8, "note": "", "info": "Brother HL-5250DN (Windows Development)", "resource": "winspool://127.0.0.1/brother_hl_5250dn__windows_development_", "name": "Brother HL-5250DN (Windows Development)", "uuid": "Brother HL-5250DN (Windows Development)", "make-and-model": "Brother HL-5250DN", "media": [ { "name": "na_letter_8.5x11in", "klass": 0, "width": 21590, "width_points": 612, "type": 5, "height": 27940, "height_points": 792, "tag": 1 }, { "name": "na_legal_8.5x14in", "width_points": 612, "width": 21590, "klass": 0, "type": 4, "height": 35560, "height_points": 1008, "tag": 5 } ], "media_ready": [ "na_letter_8.5x11in" ], "kind": 1, "device_id": "", "side_default": 0, "copy": 99, "quality_default": 4, "orientation_default": 3, "quality_supported": [ 3, 4, 5 ], "orientation_supported": [ 3, 4 ], "side_supported": [ 0, 1, 2 ], "document_format_default": "application/pdf", "document_format_supported": [ "application/pdf", "image/jpeg", "image/png", "image/urf" ], "media_default": "na_letter_8.5x11in", "state": 3, "reasons": 0, }
The various enumeration types are defined as follows:
enum QualitySupported { draft = 3, normal = 4, high = 5 } enum Side { none = 0, long_edge = 1, short_edge = 2 } enum Orientation { portrait = 3, landscape = 4, reverse_landscape = 5, reverse_portrait = 6 } enum State { idle = 3, processing = 4, stopped = 5 } enum Reasons { none = 0x0000, other = 0x0001, cover_open = 0x0002, input_tray_missing = 0x0004, marker_supply_empty = 0x0008, marker_supply_low = 0x0010, marker_waste_almost_full = 0x0020, marker_waste_full = 0x0040, media_empty = 0x0080, media_jam = 0x0100, media_low = 0x0200, media_needed = 0x0400, offline = 0x0800, paused = 0x1000, spool_area_full = 0x2000, toner_empty = 0x4000, toner_low = 0x8000 }
Submit a Print Job
Input
The start_job
command is passed a JSON object through stdin
.
The JSON object has four keys: 'user', 'dest', 'job' and 'file'.
- user (who started the print job)
- dest (destination printer)
- job (# of copies, duplex, etc.)
- file (fully qualified)
The user parameter is passed as JSON encoded text in the following format:
{ address: '192.168.1.92', user: { guid: '9868E611-176E-4DFF-B008-77A818777E07', display_name: 'John Doe', name: 'jdoe', tags: [ ], domain: 'collobos.com', } }
The dest parameter is passed as JSON encoded text and will be in the same format as what was returned from the lookup_printers
command.
The job parameters are passed as JSON encoded text with the following format:
{ margins: { bottom: 635, right: 635, top: 635, left: 635 }, orientation: 3, copies: 1, side: 0, bpp: 24, media: { height_points: 792, width_points: 612, height: 27940, width: 21590, type: 5, klass: 0, name: 'na_letter_8.5x11in' } format: 'application/pdf', first_page: 0, print_quality: 4, last_page: 0, fit_to_page: true, name: 'untitled' }
Output
The output of the start_job
command must be JSON encoded text in the following format, written to stdout
:
{ resource: "ipp://localhost/jobs/7", id: 7, name: "the_name", owner: "jdoe", pages: 7, start_time: 1497562592, end_time: 1497562598, state: 9, }
The plugin can return this object multiple times from start_job
to let Presto know the status of the job over time.
Cancel a Print Job
Input
The cancel_job
command is passed a JSON object through stdin
. The JSON object has the two keys: 'dest' and 'job'.
- dest (the destination printer) - passed as JSON encoded text in the same format as what was returned from
lookup-printers
. - job (the job that is being printed) - passed as JSON encoded text in the same format as what was returned from
start_job
.
Output
There is no output from the cancel_job
command. Success is inferred by returning a 0 exit code. Failure is inferred by any exit code other than 0.