UNPKG

barcode-tool

Version:

lightweight npm package that facilitates barcode generation and detection. It leverages the Barcode Detection API for barcode scanning directly in web browsers and provides an intuitive interface for generating various barcode formats. Seamlessly integrat

48 lines (43 loc) 1.36 kB
type DetectBarcodeParams = { image: HTMLElement | Blob | HTMLCanvasElement | HTMLImageElement | HTMLVideoElement | ImageBitmap | ImageData | SVGImageElement | undefined; formats?: string[]; }; type Barcode = { format: string; rawValue: string; }; declare function detectBarcode({ image, formats }: DetectBarcodeParams): Promise<Barcode[]>; type BarcodeFormats = { detector: string[]; generator: string[]; }; declare function getSupportedFormats(): Promise<BarcodeFormats>; declare const supportedBarcodeGeneratorFormats: string[]; type SupportedBarcodeFormats = typeof supportedBarcodeGeneratorFormats[number]; type BarcodeOptions = { format?: SupportedBarcodeFormats; width?: number; height?: number; displayValue?: boolean; text?: string; fontOptions?: string; font?: string; textAlign?: string; textPosition?: string; textMargin?: number; fontSize?: number; background?: string; lineColor?: string; margin?: number; marginTop?: number; marginBottom?: number; marginLeft?: number; marginRight?: number; valid?: (valid: any) => void; }; declare const generateBarcode: (payload: { elementId: string; value: string; options?: BarcodeOptions; }) => void; export { Barcode, DetectBarcodeParams, detectBarcode, generateBarcode, getSupportedFormats };