A Capacitor plugin that enables printing the current WebView content on iOS and Android devices. This plugin provides a native print dialog that allows users to print or save as PDF the content displayed in your Capacitor application's WebView.
- 🖨️ Print WebView content directly from your Capacitor app
- 📱 Native print dialog on iOS and Android
- 💾 Save as PDF option (platform dependent)
- 🎨 Preserves styling and formatting from your web content
- ⚡ Simple, promise-based API
- 🔧 Supports Capacitor 7
- ✅ iOS
- ✅ Android
- ❌ Web (not applicable)
npm install @webnativellc/capacitor-print-webview
npx cap syncThis plugin also supports installation via Swift Package Manager for iOS projects. Add the following to your Package.swift:
dependencies: [
.package(url: "https://github.com/damiant/capacitor-print-webview.git", from: "7.1.0")
]The plugin provides a simple print() method that displays the native print dialog with the current WebView content:
import { PrintWebview } from '@webnativellc/capacitor-print-webview';
// Print the current WebView content
async function printCurrentPage() {
try {
await PrintWebview.print();
console.log('Print dialog opened successfully');
} catch (error) {
console.error('Error opening print dialog:', error);
}
}- Receipts & Invoices: Allow users to print transaction receipts
- Reports: Enable printing of generated reports and documents
- Tickets: Print event tickets or booking confirmations
- Content Sharing: Provide a print option for articles or documentation
The plugin prints the entire content of the WebView, including:
- All visible HTML content
- CSS styling and formatting
- Images and graphics
- Dynamic content generated by JavaScript
Note: The content is rendered as it appears in the WebView at the time print() is called.
print() => Promise<void>