メインコンテンツにスキップ
@capgo/capacitor-プリンター ファイルとストレージ オープンソース

プリンター Capacitor プラグイン

Capacitor ドキュメント、HTML、PDF、画像、ウェブビューの印刷用プラグイン

インストール

bun add @capgo/capacitor-printer bunx cap sync
npm、pnpm、yarn
  • npm install @capgo/capacitor-printer
  • pnpm add @capgo/capacitor-printer
  • yarn add @capgo/capacitor-printer

ガイド

Capacitorでプリンタを使用する方法

デバイスでテスト

Capgoアプリをダウンロードし、QRコードcodeをスキャンしてください。

プリンタプラグインのプレビューQRcode

@capgo/capacitor-プリンタの使用

Capacitor プリンタプラグインは、ドキュメント、HTML、PDF、画像、ウェブビューを印刷するために使用されます。

インストール

bun add @capgo/capacitor-printer
bunx cap sync

このプラグインが公開するもの

  • printBase64 - base64形式でエンコードされたファイルを印刷するための印刷UIを提示します。
  • printFile - デバイスファイルを印刷するための印刷UIを提示します。
  • printHtml - HTMLドキュメントを印刷するための印刷UIを提示します。
  • printPdf - __CAPGO_KEEP_0__ を使用して PDF ドキュメントを印刷する UI を表示します。

サンプル使用例

printBase64

Example Usage

import { Printer } from '@capgo/capacitor-printer';

// Print a base64 encoded PDF
await Printer.printBase64({
  name: 'Invoice #12345',
  data: 'base64-encoded-pdf-data',
  mimeType: 'application/pdf',
});

// Print a base64 encoded image
await Printer.printBase64({
  name: 'Product Photo',
  data: '/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDA...',
  mimeType: 'image/jpeg',
});

printFile

デバイス ファイルを印刷する UI を表示します。

import { Printer } from '@capgo/capacitor-printer';

// iOS: Print from app documents directory
await Printer.printFile({
  name: 'Contract',
  path: 'file:///var/mobile/Containers/Data/Application/.../Documents/contract.pdf',
});

// Android: Print from content URI
await Printer.printFile({
  name: 'Receipt',
  path: 'content://com.android.providers.downloads.documents/document/123',
  mimeType: 'application/pdf',
});

// Android: Print from file path
await Printer.printFile({
  name: 'Photo',
  path: 'file:///storage/emulated/0/Download/photo.jpg',
  mimeType: 'image/jpeg',
});

printHtml

HTML ドキュメントを印刷する UI を表示します。

import { Printer } from '@capgo/capacitor-printer';

// Simple HTML document
await Printer.printHtml({
name: 'Sales Report',
html: '<html><body><h1>Q4 Sales Report</h1><p>Revenue: $125,000</p></body></html>',
});

// HTML with print-specific CSS
await Printer.printHtml({
name: 'Styled Invoice',
html: `
<html>
<head>
<style>

printPdf

PDF ドキュメントを印刷する UI を表示します。

import { Printer } from '@capgo/capacitor-printer';

// Print PDF from app storage
await Printer.printPdf({
  name: 'Annual Report 2024',
  path: 'file:///var/mobile/Containers/Data/Application/.../Documents/report.pdf',
});

// Print PDF from Android downloads
await Printer.printPdf({
  name: 'Downloaded Document',
  path: 'content://com.android.providers.downloads.documents/document/123',
});

フルリファレンス

Using @capgo/capacitor-printer から続けてください。

Capacitor プリンタ プラグインを使用している場合 Capacitorを使用して@capgo/capacitorプリンタ nativeプラグインの作業を計画し、@__CAPGO_KEEP_0__/__CAPGO_KEEP_1__プリンタと接続する Capacitorを使用して@capgo/capacitorプリンタ Capacitorを使用して@capgo/capacitorプリンタの実装詳細 はじめに Getting Startedの実装詳細 Capgo プラグインディレクトリ for the product workflow in Capgo Plugin Directory, Capacitor Capgoのプラグイン for Capacitor の実装詳細については、Capgo によって提供されるプラグインを参照してください。 プラグインの追加または更新 プラグインの追加または更新の実装詳細

FAQ

プリンタープラグインFAQ

Capacitor プリンタ プラグインを Capacitor アプリにインストールする方法は何ですか。

Run "bun add @capgo/capacitor-printer" (or "npm install @capgo/capacitor-printer"), then run "bunx cap sync" so the iOS and Android projects pick up the native code. Import it from "@capgo/capacitor-printer" in your app code.

Does @capgo/capacitor-printer work with React, Vue and Angular?

Yes. Printer is a Capacitor package, so it works with any web framework that runs inside Capacitor, including Ionic, React, Vue, Angular, Svelte and plain JavaScript.

Which Capacitor version does @capgo/capacitor-printer support?

Capgo plugins follow Capacitor&#39;s major version: use the plugin major version that matches your Capacitor major version (for example plugin v8 with Capacitor 8). The compatibility table in the GitHub README lists the maintained versions.

Is @capgo/capacitor-printer free and open source?

Yes. The source code is public on GitHub at https://github.com/Cap-go/capacitor-printer/ and the package is free to install from npm. Bug reports and pull requests are welcome.

アップデート code がプリントャーを使用する場合、アプリストアのレビューなしでアップデートできますか。

Installing or upgrading the plugin changes native code, so it needs a new store build. After that, JavaScript, HTML and CSS changes that call the plugin can ship instantly with Capgo live updates.

アプリレビューの待たなくて済むようにプリント機能の変更を配信する

プラグインがストアビルドに追加されたら、Capgo ライブアップデートは、JavaScript、HTML、および CSS の変更をユーザーに 1 分間で反映します。

Capgo で始めましょう。