Getting Started
Dieser Inhalt ist in Ihrer Sprache noch nicht verfügbar.
-
Install the plugin
Terminal-Fenster npm i @capgo/capacitor-pdf-generatorTerminal-Fenster pnpm add @capgo/capacitor-pdf-generatorTerminal-Fenster yarn add @capgo/capacitor-pdf-generatorTerminal-Fenster bun add @capgo/capacitor-pdf-generator -
Sync platforms
Terminal-Fenster npx cap syncTerminal-Fenster pnpm cap syncTerminal-Fenster yarn cap syncTerminal-Fenster bunx cap sync
Generate from HTML
import { PdfGenerator } from '@capgo/capacitor-pdf-generator';
const receiptHtml = ` <html> <body> <h1>Capgo Store</h1> <p>Thank you for your purchase.</p> </body> </html>`;
const pdf = await PdfGenerator.fromData({ data: receiptHtml, documentSize: 'A4', orientation: 'portrait', type: 'base64', fileName: 'receipt.pdf',});
if (pdf.type === 'base64') { const link = document.createElement('a'); link.href = `data:application/pdf;base64,${pdf.base64}`; link.download = 'receipt.pdf'; link.click();}Capture a remote URL
await PdfGenerator.fromURL({ url: 'https://docs.capgo.app/invoice?id=123', orientation: 'landscape', documentSize: 'A4', type: 'share', // opens the native share dialog fileName: 'invoice-123.pdf',});Tips
- Include inline CSS in your HTML string or provide a
baseUrlso relative assets resolve correctly. - When returning base64 data on mobile, move it to the filesystem (e.g., Capacitor Filesystem) before sharing.
- landscape orientation is ideal for wide tables, while portrait fits most documents.
- Consider using scoped CSS fonts (e.g., system fonts) for consistent rendering across platforms.