Skip to content

Commit 48ffcae

Browse files
zakton5ihadeed
authored andcommitted
feat(printer): add printer plugin (#225)
* feat(printer): add printer plugin * Fixed function implementations. Removed unnecessary reference.
1 parent 4c6006b commit 48ffcae

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import {LaunchNavigator} from './plugins/launchnavigator';
5252
import {LocalNotifications} from './plugins/localnotifications';
5353
import {MediaPlugin} from './plugins/media';
5454
import {Network, Connection} from './plugins/network';
55+
import {Printer} from './plugins/printer';
5556
import {Push} from './plugins/push';
5657
import {SafariViewController} from './plugins/safari-view-controller';
5758
import {Screenshot} from './plugins/screenshot';
@@ -85,6 +86,7 @@ export * from './plugins/inappbrowser';
8586
export * from './plugins/launchnavigator';
8687
export * from './plugins/localnotifications';
8788
export * from './plugins/media';
89+
export * from './plugins/printer';
8890
export * from './plugins/push';
8991
export * from './plugins/safari-view-controller';
9092
export * from './plugins/sms';
@@ -183,6 +185,7 @@ window['IonicNative'] = {
183185
LocalNotifications: LocalNotifications,
184186
MediaPlugin: MediaPlugin,
185187
Network: Network,
188+
Printer: Printer,
186189
Push: Push,
187190
SafariViewController: SafariViewController,
188191
Screenshot: Screenshot,

src/plugins/printer.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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

Comments
 (0)