1.0.0 • Published 8 months ago
@jnhtr/capacitor-plugin-printer v1.0.0
Printer.print({ content: '<b>Lorem ipsum...</b>'})Versions
| Capacitor Version | Plugin Version |
|---|---|
| v5.x | v0.0.3 |
| v6.x | v0.0.4+ |
| v7.x | v1.0.0+ |
Supported Platforms
- Android 6.0+ (API 24+)
- iOS 14.0+
Supported Contents
- HTML (can use CSS inline styling)
- Text
- Image(as HTML)
- Base64(PDF & image) (since v0.0.5)
Installation
npm install @jnhtr/capacitor-plugin-printer
npx cap syncUsage
import { Printer } from '@jnhtr/capacitor-plugin-printer';
.
.
.
Printer.print({ content: 'Lorem ipsum...', name: 'lorem-filename', orientation: 'landscape' })Examples
Text:
Printer.print({ content: 'Lorem ipsum...'})HTML:
Printer.print({ content: '<h1>Lorem</h1>'})Printing multiple HTML elements:
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>'})Base64:
// (since v0.0.5)
// Base64 decoder supports Plain text(just the Base64 value) & Data URI(data:content/type;base64)
Printer.print({ content: 'base64:...'})API
print(...)
print(printOptions: PrintOptions) => Promise<void>| Param | Type |
|---|---|
printOptions | PrintOptions |
Interfaces
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 |
Attribution & License
This plugin is licensed under the MIT License. See LICENSE for details.
Contributors
See CONTRIBUTORS.md for a full list of contributors.
Original Author
- BarisCanYesil - Original plugin creator and maintainer for Capacitor 5 & 6
Current Maintainer
- jnhtr (@jnhtr) - Capacitor 7 upgrade, platform requirements updates, and build system modernisation
Acknowledgments
Thanks to BarisCanYesil for creating this excellent printing plugin and maintaining it through multiple Capacitor versions. This fork continues that work with Capacitor 7 compatibility and ongoing maintenance.
Changelog
v1.0.0 (Capacitor 7)
- ✅ Upgraded to Capacitor 7 compatibility
- ✅ Updated minimum iOS requirement to 14.0+
- ✅ Updated minimum Android requirement to API 24+ (Android 6.0+)
- ✅ Updated all dependencies and build tools
- ✅ Improved TypeScript configuration
- ✅ Enhanced development tooling
Previous Versions
See the original repository for changelog of versions 0.0.1 - 0.0.5
1.0.0
8 months ago