메인 콘텐츠로 건너뛰기
플러그인으로 돌아가기
@capgo/capacitor-프린터
튜토리얼
github.com/Cap-go에 의해

프린터

Capacitor 플러그인: 문서, HTML, PDF, 이미지 및 웹 뷰의 출력

가이드

프린터 튜토리얼

@capgo/capacitor-프린터 사용

Capacitor 프린터 플러그인: 문서, HTML, PDF, 이미지 및 웹 뷰를 출력합니다.

설치

bun add @capgo/capacitor-printer
bunx cap sync

이 플러그인은 다음을 제공합니다.

  • printBase64 - base64로 인코딩된 파일을 인쇄하기 위한 인쇄 UI를 제공합니다.
  • printFile - 장치 파일을 인쇄하기 위한 인쇄 UI를 제공합니다.
  • printHtml - HTML 문서를 인쇄하기 위한 인쇄 UI를 제공합니다.
  • printPdf - PDF 문서를 인쇄하기 위한 인쇄 UI를 제공합니다.

사용 예

printBase64

base64로 인코딩된 파일을 인쇄하기 위한 인쇄 UI를 제공합니다.

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',
});

전체 참조

capgo에서 계속 진행하세요: Using @capgo/capacitor-printer

__CAPGO_KEEP_0__을 사용 중이라면 capgo @capgo/capacitor-printer을 사용하고 있습니다. __CAPGO_KEEP_0__을 사용하여 네이티브 플러그인 작업을 계획하고 있으시다면 capgo @capgo/capacitor-printer을 연결하세요. for the implementation detail in @capgo/capacitor-printer, __CAPGO_KEEP_0__ @__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-printer의 구현 세부 정보를 확인하세요. __CAPGO_KEEP_0__ 플러그인 디렉토리 Capgo 플러그인 디렉토리의 제품 워크플로우를 확인하세요. Capgo Capacitor 플러그인들에 의해 Capgo Capacitor 플러그인들에 의해 Capgo의 구현 세부 정보를 위해 플러그인 추가 또는 업데이트 플러그인 추가 또는 업데이트의 구현 세부 정보를 위해