Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/**
* @constructs Printer
*/
function Printer(){};
Printer.prototype = {};
/**
* Returns if printer is local or network
* @returns {boolean}
*/
Printer.prototype.isLocal = function(){return true;};
/**
* Returns if printer is shared
* @returns {boolean}
*/
Printer.prototype.isShared = function(){return true;};
/**
* Enumarates all jobs by returning job or null
* @param {number} index of job
* @returns {Object} job or null
*/
Printer.prototype.eunumarateJobs = function(index){return new PrintingJob();};
/**
* @constructs PrintingJob
*/
function PrintingJob(){};
PrintingJob.prototype = {};
PrintingJob.STATUS_PAUSED = 1;
PrintingJob.STATUS_ERROR = 2;
PrintingJob.STATUS_DELETING = 3;
PrintingJob.STATUS_SPOOLING = 4;
PrintingJob.STATUS_PRINTING = 5;
PrintingJob.STATUS_OFFLINE = 6;
PrintingJob.STATUS_PAPEROUT = 7;
PrintingJob.STATUS_PRINTED = 8;
PrintingJob.STATUS_DELETED = 9;
PrintingJob.STATUS_BLOCKED_DEVQ = 10;
PrintingJob.STATUS_USER_INTERVENTION= 11;
PrintingJob.STATUS_RESTART = 12;
/**
* @returns {string}
*/
PrintingJob.prototype.getDocumentName = function(){return "";};
/**
* @returns {string}
*/
PrintingJob.prototype.getOwnerMachineName = function(){return "";};
/**
* @returns {string}
*/
PrintingJob.prototype.getOwnerUserName = function(){return "";};
/**
* @returns {number}
*/
PrintingJob.prototype.getPagesPrinted = function(){return 0;};
/**
* @returns {number}
*/
PrintingJob.prototype.getTotalPages = function(){return 0;};
/**
* @returns {number}
*/
PrintingJob.prototype.getPosition = function(){return 0;};
/**
* @returns {number}
*/
PrintingJob.prototype.getSize = function(){return 0;};
/**
* @returns {object}
*/
PrintingJob.prototype.getSubmitTime = function(){return new Date();};
/**
* @returns {number} Returns related PrintingJob.STATUS code
*/
PrintingJob.prototype.getStatus = function(){return 0;};
/**
*/
PrintingJob.prototype.remove = function(){};
/**
*/
PrintingJob.prototype.pause = function(){};
/**
*/
PrintingJob.prototype.restart = function(){};
/**
*/
PrintingJob.prototype.resume = function(){};
/**
* @constructs PrinterManager
*/
function PrinterManager(){};
PrinterManager.prototype = {};
/**
* Enumarates all printers by returning printer or null
* @param {number} index of printer
* @returns {Object} printer or null
*/
PrinterManager.enumaratePrinters = function(index){return new Printer("");};
/**
* Returns default printer name
* @returns {Object}
*/
PrinterManager.getDefaultPrinter = function(){return new Printer("");};
/**
* Returns printer
* @param {stirng} printerName
* @returns {Object}
*/
PrinterManager.getPrinter = function(printerName){return new Printer("");};
/**
* Invokes the standard Browser Page Setup.
*/
PrinterManager.pageSetup = function(){};
/**
* Invokes the standard Browser Print Preview Page.
*/
PrinterManager.printPreview = function(){};
/**
* Sets printer name of print command
* @param {string} printerName
* @returns {boolean} false means failed, true is success.
*/
PrinterManager.setPrinter = function(printerName){return true;};
/**
* Sets printer template URL that is will be used during printing
* @param {string} templateURL
* @returns {boolean} false means failed, true is success.
*/
PrinterManager.setTemplateURL = function(templateURL){return true;};
/**
* Sets printer paper size that is will be used during printing
* @param {string} paperSize
* @returns {boolean} false means failed, true is success.
*/
PrinterManager.setPaperSize = function(paperSize){return true;};
/**
* Returns unprintable top value
* @returns {number}
*/
PrinterManager.getUnprintableTop = function(){return 0;};
/**
* Returns unprintable bottom value
* @returns {number}
*/
PrinterManager.getUnprintableBottom = function(){return 0;};
/**
* Returns unprintable left value
* @returns {number}
*/
PrinterManager.getUnprintableLeft = function(){return 0;};
/**
* Returns unprintable right value
* @returns {number}
*/
PrinterManager.getUnprintableRight = function(){return 0;};
/**
* @param {string} header
*/
PrinterManager.setHeader = function(header){};
/**
* @param {string} footer
*/
PrinterManager.setFooter = function(footer){};
/**
* @param {number} paperOrientation 1 Portrait, 2 Landscape
*/
PrinterManager.setPaperOrientation = function(paperOrientation){};
/**
* @param {boolean} printBackground
*/
PrinterManager.setPrintBackground = function(printBackground){};
/**
* @param {number} fromPageNumber
* @param {number} toPageNumber
*/
PrinterManager.setPageRange = function(fromPageNumber,toPageNumber){};
/**
* @param {string} numberOfCopies
*/
PrinterManager.setNumberOfCopies = function(numberOfCopies){};
/**
* @param {number} topMargin
*/
PrinterManager.setTopMargin = function(topMargin){};
/**
* @param {number} leftMargin
*/
PrinterManager.setLeftMargin = function(leftMargin){};
/**
* @param {number} bottomMargin
*/
PrinterManager.setBottomMargin = function(bottomMargin){};
/**
* @param {number} rightMargin
*/
PrinterManager.setRightMargin = function(rightMargin){};
/**
* Prints document
* @param {boolean} promptPrintDialog
* @returns {string} 0 means success, otherwise error code or message is returned.
*/
PrinterManager.print = function(promptPrintDialog){return true;};
/**
* Waits for all pending download and spooling operations originated with "print"
*/
PrinterManager.waitForSpoolingComplete = function(){};
/**
* @returns {boolean}
*/
PrinterManager.isSpooling = function(){return true;};
/**
* @constructs RawPrinterManager
*/
function RawPrinterManager(){};
RawPrinterManager.prototype = {};
/**
* Starts printing job
* @param {string} printerName
* @param {string} documentName
* @returns {boolean} false means failed, true success.
*/
RawPrinterManager.startPrinting = function(printerName, documentName){return true;};
/**
* Prints document at given URL
* @param {string} documentURL
* @returns {string} 0 means success, otherwise error code or message is returned.
*/
RawPrinterManager.print = function(documentURL){return true;};
/**
* Ends printing job
* @returns {string} 0 means success, otherwise error code or message is returned.
*/
RawPrinterManager.endPrinting = function(){return true;};
@suricactus

This comment has been minimized.

Copy link

suricactus commented Apr 22, 2016

Any idea whether some of the browser vendors are going to implement such API in near future. Firefox is moving to WebExtensions API and many of printing plugins will stop working without alternative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.