Capacitor plugin for printing HTML format value iOS/Android apps.
This plugin supports Capacitor v6.x
Printer.print({ content: '<b>Lorem ipsum...</b>'})
- Android 5.1+
- iOS 13+
- HTML (can use CSS inline styling)
- Text
- Image(as HTML)
npm install @bcyesil/capacitor-plugin-printer
npx cap sync
import { Printer } from '@bcyesil/capacitor-plugin-printer';
.
.
.
Printer.print({ content: 'Lorem ipsum...', name: 'lorem-filename', orientation: 'landscape' })
Text:
Printer.print({ content: 'Lorem ipsum...'})
HTML:
Printer.print({ content: '<h1>Lorem</h1>'})
Suggestion for multiple lines:
let contentTest: string = "";
contentTest += '<li style="color:green">Tea</li>'
contentTest += '<li style="font-size:50px">Coffee</li>'
contentTest += '<img src="https://picsum.photos/200">'
Printer.print({ content: contentTest })
Images with HTML:
Printer.print({ content: '<img src="base64/url/path">'})
with inline CSS:
Printer.print({ content: '<b style="color:red">Lorem ipsum</b>'})
print(printOptions: PrintOptions) => Promise<void>
Param | Type |
---|---|
printOptions |
PrintOptions |
Prop | Type | Description | Default | Since |
---|---|---|---|---|
content |
string |
HTML content for print. | 0.0.1 | |
name |
string |
Name of the print of the document. | iOS=YourAppName/Android=Document+CurrentTimestamp |
0.0.1 |
orientation |
string |
Orientation of the printing page. "portrait" or "landscape" | "portrait" |
0.0.1 |