Getting Started
이 콘텐츠는 아직 귀하의 언어로 제공되지 않습니다.
-
Install the plugin
Terminal window npm i @capgo/capacitor-pdf-generatorTerminal window pnpm add @capgo/capacitor-pdf-generatorTerminal window yarn add @capgo/capacitor-pdf-generatorTerminal window bun add @capgo/capacitor-pdf-generator -
Sync platforms
Terminal window npx cap syncTerminal window pnpm cap syncTerminal window yarn cap syncTerminal window 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.