Skip to main content

프린터에 대한 튜토리얼

장치에서 테스트

__CAPGO_KEEP_0__ 앱을 다운로드하고 QR코드 __CAPGO_KEEP_1__를 스캔하세요.

Download the Capgo app, then scan the QR code.

인쇄 플러그인 미리보기 QR code

@capgo/capacitor-인쇄기를 사용합니다.

Capacitor plugin for printing documents, HTML, PDFs, images and web views.

설치

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

출력 UI를 사용하여 HTML 문서를 인쇄합니다.

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

출력 UI를 사용하여 PDF 문서를 인쇄합니다.

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

전체 참조

Keep going from Using @capgo/capacitor-printer

Capgo를 사용하여 native 플러그인 작업을 계획하고 있습니다. Using @capgo/capacitor-printer Capgo를 사용하여 native 플러그인 작업을 계획하고 있습니다. @capgo/capacitor-printer Capacitor 프린터 구현 세부 사항을 위해 @capgo/capacitor-프린터를 사용합니다. 시작하기 Capacitor 프린터 구현 세부 사항을 위해 시작하기를 사용합니다. Capgo 플러그인 디렉토리 Capacitor 프린터 제품 워크플로우를 위해 Capgo 플러그인 디렉토리를 사용합니다. Capacitor 플러그인들 - Capgo Capacitor 프린터 구현 세부 사항을 위해 Capacitor 플러그인들 - Capgo을 사용합니다. 플러그인 추가 또는 업데이트 Capacitor 프린터 구현 세부 사항을 위해 플러그인 추가 또는 업데이트 를 사용합니다.