Capacitor plugin for printing.
- 🖥️ Cross-platform: Supports Android and iOS.
- 🖨️ PDF Printer: Print PDF files.
- 🖨️ HTML Printer: Print custom HTML content.
- 🖨️ Web View Printer: Print web view content.
- 🔁 Up-to-date: Always supports the latest Capacitor version.
- ⭐️ Support: First-class support from the Capawesome Team.
This plugin is only available to Capawesome Insiders. First, make sure you have the Capawesome npm registry set up. You can do this by running the following commands:
npm config set @capawesome-team:registry https://npm.registry.capawesome.io
npm config set //npm.registry.capawesome.io/:_authToken <YOUR_LICENSE_KEY>
Attention: Replace <YOUR_LICENSE_KEY>
with the license key you received from Polar. If you don't have a license key yet, you can get one by becoming a Capawesome Insider.
Next, install the package:
npm install @capawesome-team/capacitor-printer
npx cap sync
This plugin will use the following project variables (defined in your app’s variables.gradle
file):
$androidxDocumentFileVersion
version ofandroidx.documentfile:documentfile
(default:1.0.1
)
No configuration required for this plugin.
A working example can be found here: robingenz/capacitor-plugin-demo
Android | iOS |
---|---|
import { Printer } from '@capawesome-team/capacitor-printer';
const printHtml = async () => {
await Printer.printHtml({
name: 'My Document',
html: '<h1>Hello World</h1>',
});
};
const printPdf = async () => {
await Printer.printPdf({
name: 'My Document',
path: 'content://com.android.providers.downloads.documents/document/msf%3A1000000485',
});
};
const printWebView = async () => {
await Printer.printWebView({
name: 'My Document',
});
};
printHtml(options: PrintHtmlOptions) => Promise<void>
Present the printing user interface to print a html document.
Only available on Android and iOS.
Param | Type |
---|---|
options |
PrintHtmlOptions |
Since: 5.0.0
printPdf(options: PrintPdfOptions) => Promise<void>
Present the printing user interface to print a pdf document.
Only available on Android and iOS.
Param | Type |
---|---|
options |
PrintPdfOptions |
Since: 5.1.0
printWebView(options?: PrintOptions | undefined) => Promise<void>
Present the printing user interface to print the web view content.
You can use a print style sheet to customize the print output (see https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_media_queries/Printing).
Param | Type |
---|---|
options |
PrintOptions |
Since: 5.0.0
Prop | Type | Description | Since |
---|---|---|---|
html |
string |
The HTML content to print. | 5.0.0 |
Prop | Type | Description | Since |
---|---|---|---|
path |
string |
The path to the pdf document on the device. | 5.1.0 |
Prop | Type | Description | Default | Since |
---|---|---|---|---|
name |
string |
The name of the print job. | 'Document' |
5.0.0 |
See CHANGELOG.md.
See LICENSE.