2016-07-18 02:05:49 +08:00
|
|
|
import { Cordova, Plugin } from './plugin';
|
|
|
|
|
|
|
|
|
2016-06-15 23:39:01 +08:00
|
|
|
declare var cordova: any;
|
|
|
|
|
|
|
|
export interface PrintOptions {
|
2016-07-18 02:05:49 +08:00
|
|
|
/**
|
|
|
|
* The name of the print job and the document
|
|
|
|
*/
|
|
|
|
name?: string;
|
2016-06-15 23:39:01 +08:00
|
|
|
|
2016-07-18 02:05:49 +08:00
|
|
|
/**
|
|
|
|
* The network URL of the printer.
|
|
|
|
* Only supported on iOS.
|
|
|
|
*/
|
|
|
|
printerId?: string;
|
2016-06-15 23:39:01 +08:00
|
|
|
|
2016-07-18 02:05:49 +08:00
|
|
|
/**
|
|
|
|
* Specifies the duplex mode to use for the print job.
|
|
|
|
* Either double-sided (duplex:true) or single-sided (duplex:false).
|
|
|
|
* Double-sided by default.
|
|
|
|
* Only supported on iOS
|
|
|
|
*/
|
|
|
|
duplex?: boolean;
|
2016-06-15 23:39:01 +08:00
|
|
|
|
2016-07-18 02:05:49 +08:00
|
|
|
/**
|
|
|
|
* The orientation of the printed content, portrait or landscape
|
|
|
|
* Portrait by default.
|
|
|
|
*/
|
|
|
|
landscape?: boolean;
|
2016-06-15 23:39:01 +08:00
|
|
|
|
2016-07-18 02:05:49 +08:00
|
|
|
/**
|
|
|
|
* If your application only prints black text, setting this property to true can result in better performance in many cases.
|
|
|
|
* False by default.
|
|
|
|
*/
|
|
|
|
grayscale?: boolean;
|
2016-06-15 23:39:01 +08:00
|
|
|
|
2016-07-18 02:05:49 +08:00
|
|
|
/**
|
|
|
|
* The Size and position of the print view
|
|
|
|
*/
|
|
|
|
bounds?: number[] | any;
|
2016-06-15 23:39:01 +08:00
|
|
|
}
|
2016-08-11 19:55:26 +08:00
|
|
|
/**
|
|
|
|
* @name Printer
|
|
|
|
* @description Prints documents or HTML rendered content
|
|
|
|
* @usage
|
|
|
|
* ```typescript
|
|
|
|
* import {Printer, PrintOptions} from 'ionic-native';
|
|
|
|
*
|
|
|
|
* Printer.isAvailable().then(onSuccess, onError);
|
|
|
|
*
|
|
|
|
* let options: PrintOptions = {
|
|
|
|
* name: 'MyDocument',
|
|
|
|
* printerId: 'printer007',
|
|
|
|
* duplex: true,
|
|
|
|
* landscape: true,
|
|
|
|
* grayscale: true
|
|
|
|
* };
|
|
|
|
*
|
|
|
|
* Printer.print(content, options).then(onSuccess, onError);
|
|
|
|
* ```
|
|
|
|
*/
|
2016-06-15 23:39:01 +08:00
|
|
|
@Plugin({
|
2016-10-18 09:33:17 +08:00
|
|
|
name: 'Printer',
|
2016-07-18 02:05:49 +08:00
|
|
|
plugin: 'de.appplant.cordova.plugin.printer',
|
|
|
|
pluginRef: 'cordova.plugins.printer',
|
|
|
|
repo: 'https://github.com/katzer/cordova-plugin-printer.git',
|
|
|
|
platforms: ['Android', 'iOS']
|
2016-06-15 23:39:01 +08:00
|
|
|
})
|
|
|
|
export class Printer {
|
|
|
|
|
2016-07-18 02:05:49 +08:00
|
|
|
/**
|
|
|
|
* Checks whether to device is capable of printing.
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
static isAvailable(): Promise<boolean> { return; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sends content to the printer.
|
|
|
|
* @param {content} The content to print. Can be a URL or an HTML string. If a HTML DOM Object is provided, its innerHtml property value will be used.
|
|
|
|
* @param {options} The options to pass to the printer
|
|
|
|
*/
|
|
|
|
@Cordova()
|
|
|
|
static print(content: string | HTMLElement, options?: PrintOptions): Promise<any> { return; }
|
2016-06-15 23:39:01 +08:00
|
|
|
|
|
|
|
}
|