メインコンテンツへスキップ

スタートガイド

GitHub

AIアシストによるセットアップでプラグインをインストールできます。以下のコマンドを使用して、お使いのAIツールに Capgo のスキルを追加してください:

ターミナル
bunx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

次に、以下のプロンプトを使用します:

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-pdf-viewer` plugin in my project.

手動セットアップを希望する場合は、以下のコマンドを実行してプラグインをインストールし、下記のプラットフォーム別の手順に従ってください:

ターミナル
bun add @capgo/capacitor-pdf-viewer
bunx cap sync
import { PdfViewer } from '@capgo/capacitor-pdf-viewer';
import { PdfViewer } from '@capgo/capacitor-pdf-viewer';
const result = await PdfViewer.open({
source: 'https://example.com/manual.pdf',
headers: { Authorization: 'Bearer token' },
mode: 'fullscreen',
});
  • リスナー: 画面がアンマウントされたらハンドルを削除します。
  • ネイティブ同期: 実行 bunx cap sync プラグインのアップグレード後。
  • 信頼できる情報源: 信頼 src/definitions.ts GitHub リポジトリ内。

プラットフォームのセットアップ

「プラットフォームのセットアップ」セクション
import { PdfViewer } from '@capgo/capacitor-pdf-viewer';
await PdfViewer.addListener('pageChange', ({ page, pageCount }) => {
console.log(`Page ${page} of ${pageCount}`);
});
const { pageCount } = await PdfViewer.open({
source: 'https://example.com/manual.pdf',
headers: { Authorization: 'Bearer YOUR_TOKEN' },
mode: 'fullscreen',
scrollMode: 'continuous',
page: 1,
});
console.log(`Opened ${pageCount} pages`);
// Call PdfViewer.close() when the user dismisses the viewer or you navigate away.