|
| 1 | +import {Plugin, Cordova} from './plugin'; |
| 2 | +declare var cordova: any; |
| 3 | + |
| 4 | +export interface PrintOptions { |
| 5 | + /** |
| 6 | + * The name of the print job and the document |
| 7 | + */ |
| 8 | + name?: string; |
| 9 | + |
| 10 | + /** |
| 11 | + * The network URL of the printer. |
| 12 | + * Only supported on iOS. |
| 13 | + */ |
| 14 | + printerId?: string; |
| 15 | + |
| 16 | + /** |
| 17 | + * Specifies the duplex mode to use for the print job. |
| 18 | + * Either double-sided (duplex:true) or single-sided (duplex:false). |
| 19 | + * Double-sided by default. |
| 20 | + * Only supported on iOS |
| 21 | + */ |
| 22 | + duplex?: boolean; |
| 23 | + |
| 24 | + /** |
| 25 | + * The orientation of the printed content, portrait or landscape |
| 26 | + * Portrait by default. |
| 27 | + */ |
| 28 | + landscape?: boolean; |
| 29 | + |
| 30 | + /** |
| 31 | + * If your application only prints black text, setting this property to true can result in better performance in many cases. |
| 32 | + * False by default. |
| 33 | + */ |
| 34 | + grayscale?: boolean; |
| 35 | + |
| 36 | + /** |
| 37 | + * The Size and position of the print view |
| 38 | + */ |
| 39 | + bounds?: number[] | any; |
| 40 | +} |
| 41 | + |
| 42 | + |
| 43 | +@Plugin({ |
| 44 | + plugin: 'de.appplant.cordova.plugin.printer', |
| 45 | + pluginRef: 'cordova.plugins.printer', |
| 46 | + repo: 'https://github.com/katzer/cordova-plugin-printer.git', |
| 47 | + platforms: ['Android', 'iOS'] |
| 48 | +}) |
| 49 | +export class Printer { |
| 50 | + |
| 51 | + /** |
| 52 | + * Checks whether to device is capable of printing. |
| 53 | + */ |
| 54 | + @Cordova() |
| 55 | + static isAvailable(): Promise<boolean> { return; } |
| 56 | + |
| 57 | + /** |
| 58 | + * Sends content to the printer. |
| 59 | + * @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. |
| 60 | + * @param {options} The options to pass to the printer |
| 61 | + */ |
| 62 | + @Cordova() |
| 63 | + static print(content: string | HTMLElement, options?: PrintOptions): Promise<any> { return; } |
| 64 | +} |
0 commit comments