Print files or the current web view from a Capacitor app.
This plugin wraps the native printing UI on iOS and Android. You can print a local file (for example, a PDF generated in your app) or the content of the current web view.
Full documentation: https://docs.rdlabo.dev/projects/capacitor-printer
Documentation: Read the full documentation
npm install @rdlabo/capacitor-printer
npx cap syncSee PDF to print a file and Web to print the current WebView.
import { Printer } from '@rdlabo/capacitor-printer';
const printPdf = async (filePath: string) => {
try {
await Printer.printFile({
path: filePath,
mimeType: 'application/pdf',
});
} finally {
// The source file can be deleted once the promise settles.
}
};import { Printer } from '@rdlabo/capacitor-printer';
const printPage = async () => {
await Printer.printWebView({ name: 'My Receipt' });
};Use this plugin when your app needs to present the system print dialog, such as:
- Printing a receipt or invoice as PDF.
- Printing a report generated in the app.
- Printing the contents of the current page.
- iOS and Android:
printFileandprintWebVieware both supported. - Web: Not supported because browsers already provide
window.print().
printFile(options: PrintFileOptions) => Promise<void>Present the printing user interface to print a file.
The promise settles after the operating system no longer needs the source
file, so the file can be safely deleted in a finally block.
Only available on Android and iOS.
| Param | Type |
|---|---|
options |
PrintFileOptions |
printWebView(options?: PrintOptions | undefined) => Promise<void>Present the printing user interface to print the web view content.
| Param | Type |
|---|---|
options |
PrintOptions |
| Prop | Type | Description |
|---|---|---|
path |
string |
The path to the file. Android supports file paths, file:// URLs, and content:// URLs. iOS supports file paths and local file:// URLs. |
mimeType |
string |
The MIME type of the file. Only used on Android. |
| Prop | Type | Description | Default |
|---|---|---|---|
name |
string |
The name of the print job. | 'Document' |
An open, non-draft pull request can be published to the npm beta dist-tag after its Validation and Package Candidate workflows pass. A repository owner or maintainer must add a comment whose entire body is:
/beta
The request authorizes only the pull request head SHA that existed when the comment was added. The workflow revalidates the owner or maintainer permission and head SHA immediately before publishing. Any new commit requires CI to pass again and a fresh owner or maintainer /beta comment. Fork pull requests are supported. Pull requests that change a release-gating workflow cannot be beta-published until those workflow changes land on main.
Beta versions use <base>-beta.pr<PR number>.sha<12-character SHA>. The candidate is built in a read-only workflow without npm publishing credentials. The privileged release workflow publishes only the validated immutable package artifact with lifecycle scripts disabled. A notification failure cannot invalidate a successful npm publish.
When a pull request is merged into main, it is automatically published to beta only after the required CI and Package Candidate succeed for that exact merge commit. Direct pushes to main do not publish a candidate.
Only npm run release creates a release tag. Stable vX.Y.Z tags publish to npm latest; revision/prerelease tags publish to next. Neither beta nor next publishing changes the npm latest dist-tag.
This project is licensed under the MIT License.