### Install ReceiptIO Source: https://github.com/receiptline/receiptio/blob/main/README.md Global installation of the ReceiptIO CLI tool. ```bash $ npm install -g receiptio ``` -------------------------------- ### View CLI Help and Usage Examples Source: https://github.com/receiptline/receiptio/blob/main/README.md Display the help menu and common usage patterns for the receiptio command. ```console $ receiptio -h usage: receiptio [options] [source] source: receipt markdown text file https://receiptline.github.io/designer/ if source is not present, standard input options: -h show help -d ip address or serial/usb port of target printer -o file to output (if -d option is not present) if -d and -o are not present, standard output -q [] inquire status (printer/drawer/drawer2) (default: printer) -c characters per line (24-96) (default: 48) -u upside down -v landscape orientation (for escpos/epson/sii/citizen/star) -r print resolution for -v (180/203) (default: 203) -s paper saving (reduce line spacing) -n no paper cut -m [][,] print margin (left: 0-24, right: 0-24) (default: 0,0) -i print as image (requires puppeteer or sharp) -b image thresholding (0-255) -g image gamma correction (0.1-10.0) (default: 1.0) -t print timeout (0-3600 sec) (default: 300) -l language of source file (default: system locale) (en/fr/de/es/po/it/ru/ja/ko/zh-hans/zh-hant/th/...) -p printer control language (default: auto detection) (escpos/epson/sii/citizen/fit/impact/impactb/generic/ star/starline/emustarline/stargraphic/ starimpact/starimpact2/starimpact3/svg/png/txt/text) (png requires puppeteer or sharp) print results: success(0), online(100), coveropen(101), paperempty(102), error(103), offline(104), disconnect(105), timeout(106), drawerclosed(200), draweropen(201) examples: receiptio -d com9 -q receiptio -d COM1 example.receipt receiptio -d /dev/usb/lp0 example.receipt receiptio -d /dev/ttyS0 -u -b 160 example.receipt receiptio -d 192.168.192.168 -c 42 example.receipt receiptio example.receipt -o receipt.png receiptio example.receipt -o receipt.txt receiptio example.receipt -p escpos -i -b 128 -g 1.8 -o receipt.prn receiptio < example.receipt > receipt.svg echo {c:1234567890} | receiptio | more ``` -------------------------------- ### Install ReceiptIO and Dependencies Source: https://context7.com/receiptline/receiptio/llms.txt Install ReceiptIO globally or as a project dependency. Optional dependencies like 'serialport' for serial connections or 'puppeteer'/'sharp' for image output can also be installed. ```bash # Install globally for CLI usage npm install -g receiptio ``` ```bash # Install as project dependency npm install receiptio ``` ```bash # Optional: For serial port connections npm install -g serialport ``` ```bash # Optional: For image output (PNG) - choose one npm install -g puppeteer # Full web font support ``` ```bash npm install -g sharp # Lightweight alternative ``` -------------------------------- ### Install Dependencies Source: https://github.com/receiptline/receiptio/blob/main/README.md Install optional dependencies for serial port communication or image processing. ```bash $ npm install -g serialport ``` ```bash $ npm install -g puppeteer ``` ```bash $ npm install -g sharp ``` -------------------------------- ### Serial Port Options Example Source: https://github.com/receiptline/receiptio/blob/main/README.md Example of specifying serial port connection options, including baud rate, parity, data bits, and stop bits. ```bash -d COM1:115200,N,8,1 ``` -------------------------------- ### Print Receipt via CLI Source: https://github.com/receiptline/receiptio/blob/main/README.md Demonstrates creating a receipt markdown file and printing it to a network printer using the command line. ```bash $ more example.receipt ^^^RECEIPT 12/18/2021, 11:22:33 AM Asparagus | 1| 1.00 Broccoli | 2| 2.00 Carrot | 3| 3.00 --- ^TOTAL | ^6.00 $ receiptio -d 192.168.192.168 -c 42 example.receipt success ``` -------------------------------- ### Configure Linux USB Permissions Source: https://github.com/receiptline/receiptio/blob/main/README.md Add a user to the lp group to enable access to USB printer device files on Linux. ```bash $ sudo gpasswd -a USER lp ``` -------------------------------- ### Print API Usage Source: https://github.com/receiptline/receiptio/blob/main/README.md Demonstrates how to use the receiptio.print method with both async/await and promise-based syntax. ```javascript // async/await const result = await receiptio.print(markdown, options); console.log(result); // promise receiptio.print(markdown, options).then(result => { console.log(result); }); ``` -------------------------------- ### Configure ReceiptIO in Node.js Source: https://context7.com/receiptline/receiptio/llms.txt Implementation of print options and serial port configuration using the Node.js API. ```javascript const receiptio = require('receiptio'); // Full options example const options = [ '-d 192.168.192.168', // Destination: IP address, serial port, or USB device '-c 42', // Characters per line: 24-96 (default: 48) '-u', // Upside down printing '-v', // Landscape orientation '-r 203', // Resolution for landscape: 180 or 203 (default: 203) '-s', // Paper saving (reduce line spacing) '-n', // No paper cut after printing '-m 2,2', // Print margins: left,right (0-24, default: 0,0) '-i', // Print as image (requires puppeteer or sharp) '-b 128', // Image threshold: 0-255 '-g 1.0', // Gamma correction: 0.1-10.0 (default: 1.0) '-t 300', // Print timeout: 0-3600 seconds (default: 300) '-l en', // Language: en/fr/de/es/po/it/ru/ja/ko/zh-hans/zh-hant/th '-p epson', // Printer type: escpos/epson/sii/citizen/fit/impact/ // impactb/generic/star/starline/emustarline/ // stargraphic/starimpact/svg/png/txt/text ].join(' '); receiptio.print(markdown, options).then(result => { console.log(result); }); ``` ```javascript // Serial port with full configuration // Format: path:baudrate,parity,databits,stopbits,flowcontrol receiptio.print(markdown, '-d COM1:115200,N,8,1,N').then(result => { console.log(result); }); ``` -------------------------------- ### CLI Usage Source: https://context7.com/receiptline/receiptio/llms.txt Command-line interface for ReceiptIO, providing direct access to printing and conversion features with various options for input and output. ```APIDOC ## CLI Usage ### Description The command-line interface provides direct access to all printing and conversion features, supporting file input, stdin/stdout redirection, and various output formats. ### Examples **Printing to Printers:** - **Print to network printer:** ```bash receiptio -d 192.168.192.168 -c 42 receipt.receipt ``` - **Print to serial port (Windows):** ```bash receiptio -d COM1 receipt.receipt ``` - **Print to serial port with options (Linux):** ```bash receiptio -d /dev/ttyS0:115200,N,8,1 receipt.receipt ``` - **Print to USB device (Linux):** ```bash receiptio -d /dev/usb/lp0 receipt.receipt ``` **Querying Printer/Drawer Status:** - **Query printer status:** ```bash receiptio -d 192.168.192.168 -q # Output: online, coveropen, paperempty, error, offline, or disconnect ``` - **Query cash drawer status:** ```bash receiptio -d 192.168.192.168 -q drawer # Output: drawerclosed or draweropen ``` **Converting Receipt Content:** - **Convert to SVG file:** ```bash receiptio receipt.receipt -o receipt.svg ``` - **Convert to PNG file:** ```bash receiptio receipt.receipt -o receipt.png ``` - **Convert to plain text:** ```bash receiptio receipt.receipt -o receipt.txt ``` **Advanced Options:** - **Print upside down with paper saving:** ```bash receiptio -d 192.168.192.168 -u -s receipt.receipt ``` ### Parameters - **-d ** : Specifies the printer device (IP address, serial port, USB path). - **-c ** : Sets the number of characters per line. - **-p ** : Specifies the output format for conversion (svg, png, txt). - **-q [query_type]** : Queries the printer status (default) or cash drawer status. - **-o ** : Specifies the output file for converted content. - **-u** : Prints upside down. - **-s** : Saves paper (reduces whitespace). (Note: The input receipt content can be provided as a file path or piped via stdin.) ``` -------------------------------- ### CLI: Print to USB Device (Linux) Source: https://context7.com/receiptline/receiptio/llms.txt Print to a USB printer connected to a Linux system using the ReceiptIO CLI by specifying the USB device file path. ```bash # Print to USB device (Linux) receiptio -d /dev/usb/lp0 receipt.receipt ``` -------------------------------- ### CLI: Print to Serial Port (Windows) Source: https://context7.com/receiptline/receiptio/llms.txt Use the ReceiptIO CLI to print to a serial port on Windows by specifying the COM port name. ```bash # Print to serial port (Windows) receiptio -d COM1 receipt.receipt ``` -------------------------------- ### CLI: Print to Serial Port (Linux) Source: https://context7.com/receiptline/receiptio/llms.txt Print to a serial port on Linux using the ReceiptIO CLI. Specify the device path and connection parameters (baud rate, parity, data bits, stop bits). ```bash # Print to serial port with options (Linux) receiptio -d /dev/ttyS0:115200,N,8,1 receipt.receipt ``` -------------------------------- ### CLI: Query Cash Drawer Status Source: https://context7.com/receiptline/receiptio/llms.txt Use the ReceiptIO CLI with the printer's IP address and '-q drawer' to check if the cash drawer is open or closed. ```bash # Query cash drawer status receiptio -d 192.168.192.168 -q drawer # Output: drawerclosed or draweropen ``` -------------------------------- ### CLI: Convert to PNG File Source: https://context7.com/receiptline/receiptio/llms.txt Convert a receipt file to a PNG image file using the ReceiptIO CLI. Use the '-o' flag to specify the output PNG file name. ```bash # Convert to PNG file receiptio receipt.receipt -o receipt.png ``` -------------------------------- ### Serial Port Options Source: https://github.com/receiptline/receiptio/blob/main/README.md Configuration options for serial port connections. ```APIDOC # Serial port options ``` -d COM1:115200,N,8,1 ``` - `-d ` - the system path of the serial port - `[:]` - `` - `,,,[,]` - default: `115200,N,8,1,N` - commas can be omitted - `` - `2400`, `4800`, `9600`, `19200`, `38400`, `57600`, `115200` - `` - `N`: none, `E`: even, `O`: odd - `` - `8`, `7` - `` - `1`, `2` - `` - `N`: none, `R`: rts/cts, `X`: xon/xoff ``` -------------------------------- ### CLI: Convert to Plain Text Source: https://context7.com/receiptline/receiptio/llms.txt Convert a receipt file to plain text format using the ReceiptIO CLI. Specify the input receipt file and use '-o' for the output text file. ```bash # Convert to plain text receiptio receipt.receipt -o receipt.txt ``` -------------------------------- ### Build and Print Transaction Receipt Source: https://context7.com/receiptline/receiptio/llms.txt Constructs a detailed transaction receipt object and prints it to a network printer. Ensure the printer IP address is correctly specified. Handles success and error callbacks. ```javascript const receiptio = require('receiptio'); // Build a complete transaction receipt const transaction = { store: 'ACME STORE', address: '123 Main Street', phone: '555-1234', datetime: new Date().toLocaleString(), items: [ { name: 'Widget A', qty: 2, price: 9.99 }, { name: 'Widget B', qty: 1, price: 14.99 }, { name: 'Service Fee', qty: 1, price: 2.50 }, ], subtotal: 37.47, tax: 3.00, total: 40.47, payment: 'VISA ****1234', orderId: 'ORD-2024-0001' }; const receipt = ` ^^^${transaction.store} ${transaction.address} Tel: ${transaction.phone} ${'-'.repeat(42)} ${transaction.datetime} ${'-'.repeat(42)} ${transaction.items.map(i => `${i.name.padEnd(20)}${String(i.qty).padStart(3)} x ${i.price.toFixed(2).padStart(7)}` ).join('\n')} ${'='.repeat(42)} |Subtotal:|${transaction.subtotal.toFixed(2)} |Tax:|${transaction.tax.toFixed(2)} --- ^^|TOTAL:|^^$${transaction.total.toFixed(2)} ${'='.repeat(42)} Payment: ${transaction.payment} {q:${transaction.orderId}} |${transaction.orderId}| |Thank you for your purchase!| `; // Print to network printer receiptio.print(receipt, '-d 192.168.192.168 -c 42') .then(result => { if (result === 'success') { console.log('Receipt printed successfully'); } else { console.error('Print failed:', result); } }) .catch(err => console.error('Error:', err)); ``` -------------------------------- ### CLI: Print to Network Printer Source: https://context7.com/receiptline/receiptio/llms.txt Print a receipt file to a network printer using the ReceiptIO CLI. Specify the printer's IP address and character width. ```bash # Print to network printer receiptio -d 192.168.192.168 -c 42 receipt.receipt ``` -------------------------------- ### CLI: Convert to SVG File Source: https://context7.com/receiptline/receiptio/llms.txt Convert a receipt file to an SVG file using the ReceiptIO CLI. Specify the input receipt file and use the '-o' flag for the output SVG file. ```bash # Convert to SVG file receiptio receipt.receipt -o receipt.svg ``` -------------------------------- ### Node.js Print API Source: https://context7.com/receiptline/receiptio/llms.txt Programmatically send receipt markdown to a printer using the ReceiptIO Node.js library. ```APIDOC ## receiptio.print(markdown, options) ### Description Sends formatted receipt markdown to a specified printer or output format. ### Parameters - **markdown** (string) - Required - The receipt content formatted using ReceiptIO markdown syntax. - **options** (string) - Optional - A string of CLI-style flags defining printer destination, language, and formatting settings. ### Request Example ```javascript const markdown = "^^^RECEIPT\n\nItem | Price\n--- | ---\nApple | 1.00"; const options = "-d 192.168.192.168 -p epson"; receiptio.print(markdown, options).then(result => { console.log(result); }); ``` ### Response #### Success Response (0) - **result** (number) - Returns 0 on successful completion. #### Error Handling - **100** - Printer is online - **101** - Printer cover is open - **102** - No receipt paper - **103** - Printer error - **104** - Printer is off or offline - **105** - Printer is not connected - **106** - Print timeout exceeded ``` -------------------------------- ### Create Print Transform Stream Source: https://github.com/receiptline/receiptio/blob/main/README.md Use this to pipe receipt markdown from a readable stream to a writable stream, transforming it into a specified printer format like SVG. ```javascript const fs = require('fs'); const receiptio = require('receiptio'); const source = fs.createReadStream('example.receipt'); const transform = receiptio.createPrint('-p svg'); const destination = fs.createWriteStream('example.svg'); source.pipe(transform).pipe(destination); ``` -------------------------------- ### Print Receipts via CLI Source: https://context7.com/receiptline/receiptio/llms.txt Common command-line operations for printing receipts, including orientation, image conversion, piping, and printer language selection. ```bash receiptio -d 192.168.192.168 -v receipt.receipt ``` ```bash receiptio -d 192.168.192.168 -i -b 128 -g 1.8 receipt.receipt ``` ```bash cat receipt.receipt | receiptio > receipt.svg echo "{c:1234567890}" | receiptio | more ``` ```bash receiptio -p epson -d 192.168.192.168 receipt.receipt receiptio -p star -d 192.168.192.168 receipt.receipt ``` ```bash receiptio -l ja -d 192.168.192.168 receipt.receipt # Japanese receiptio -l zh-hans -d 192.168.192.168 receipt.receipt # Simplified Chinese ``` -------------------------------- ### Create Receipt Transform Stream Source: https://context7.com/receiptline/receiptio/llms.txt Use receiptio.createPrint() to create a transform stream for processing receipt markdown. This is useful for piping data from files or stdin. ```javascript const fs = require('fs'); const receiptio = require('receiptio'); // Convert receipt file to SVG file using streams const source = fs.createReadStream('receipt.receipt'); const transform = receiptio.createPrint('-p svg -c 48'); const destination = fs.createWriteStream('receipt.svg'); source.pipe(transform).pipe(destination); ``` ```javascript // Print from file to network printer const input = fs.createReadStream('order.receipt'); const printer = receiptio.createPrint('-d 192.168.192.168 -c 42'); const output = process.stdout; input.pipe(printer).pipe(output); ``` ```javascript // Convert stdin to PNG file process.stdin .pipe(receiptio.createPrint('-p png -c 42')) .pipe(fs.createWriteStream('receipt.png')); ``` -------------------------------- ### Receipt Markdown Syntax Source: https://context7.com/receiptline/receiptio/llms.txt Reference for the specialized markdown syntax used to format receipts. ```APIDOC ## Receipt Markdown Syntax ### Text Formatting - `^^^` - Triple height, centered - `^` - Double size text - `_text_` - Underlined text - `"text"` - Bold/emphasized text - `` `text` `` - Inverted text (white on black) ### Layout - `|centered text|` - Center aligned - `|right aligned` - Right aligned - `---` - Horizontal rule / separator ### Special Elements - `{c:data}` - Barcode (Code 128) - `{q:url}` - QR Code - `{i:base64}` - Inline image ``` -------------------------------- ### Print Receipt via Node.js API Source: https://github.com/receiptline/receiptio/blob/main/README.md Programmatically print receipt markdown using the receiptio Node.js module. ```javascript const receiptio = require('receiptio'); const markdown = `^^^RECEIPT 12/18/2021, 11:22:33 AM Asparagus | 1| 1.00 Broccoli | 2| 2.00 Carrot | 3| 3.00 --- ^TOTAL | ^6.00`; receiptio.print(markdown, '-d 192.168.192.168 -c 42').then(result => { console.log(result); }); ``` -------------------------------- ### CLI: Query Printer Status Source: https://context7.com/receiptline/receiptio/llms.txt Check the status of a printer via the CLI by providing the printer's IP address and the '-q' flag. The output indicates the printer's current state. ```bash # Query printer status receiptio -d 192.168.192.168 -q # Output: online, coveropen, paperempty, error, offline, or disconnect ``` -------------------------------- ### receiptio.print() API Source: https://context7.com/receiptline/receiptio/llms.txt The main API function to print receipts, query printer status, or convert receipt markdown to printer commands or images. It accepts markdown text and options, returning a promise with the result. ```APIDOC ## receiptio.print() ### Description The main API function that prints receipts to a printer, queries printer status, or converts receipt markdown to printer commands or images. It accepts receipt markdown text and an options string, returning a promise that resolves with the print result, printer status, or generated output. ### Method `receiptio.print(markdown, options)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **markdown** (string) - Required - The receipt content in markdown-like syntax. - **options** (string) - Required - A string of command-line options (e.g., `-d `, `-c `, `-p `, `-q `). ### Request Example ```javascript const receiptio = require('receiptio'); const markdown = `^^^RECEIPT ${new Date().toLocaleString()} Asparagus | 1| 1.00 Broccoli | 2| 2.00 Carrot | 3| 3.00 --- ^TOTAL | ^6.00 {c:1234567890}`; // Print to network printer with 42 characters per line receiptio.print(markdown, '-d 192.168.192.168 -c 42').then(result => { console.log(result); // 'success', 'coveropen', 'paperempty', 'error', 'offline', 'disconnect', or 'timeout' }); // Convert to SVG (no printer destination) receiptio.print(markdown, '-p svg -c 42').then(svg => { console.log(svg); // SVG string output }); // Convert to PNG image receiptio.print(markdown, '-p png -c 42').then(pngBase64 => { // PNG image as base64 string require('fs').writeFileSync('receipt.png', pngBase64, 'base64'); }); // Query printer status without printing receiptio.print('', '-d 192.168.192.168 -q printer').then(status => { console.log(status); // 'online', 'coveropen', 'paperempty', 'error', 'offline', or 'disconnect' }); // Query cash drawer status receiptio.print('', '-d 192.168.192.168 -q drawer').then(status => { console.log(status); // 'drawerclosed' or 'draweropen' }); ``` ### Response #### Success Response (200) - **result** (string) - For printing: 'success', 'coveropen', 'paperempty', 'error', 'offline', 'disconnect', or 'timeout'. - **output** (string) - For conversion: SVG string, PNG base64 string, or plain text. - **status** (string) - For queries: printer status ('online', 'coveropen', etc.) or drawer status ('drawerclosed', 'draweropen'). #### Response Example ```json "success" ``` ```json "..." ``` ```json "iVBORw0KGgoAAAANSUhEUgAA..." ``` ```json "online" ``` ``` -------------------------------- ### receiptio.createPrint() API Source: https://context7.com/receiptline/receiptio/llms.txt Creates a transform stream for processing receipt markdown, suitable for piping file streams or stdin/stdout operations. This is the stream-based version of the print function. ```APIDOC ## receiptio.createPrint() ### Description Creates a transform stream for processing receipt markdown, useful for piping file streams or stdin/stdout operations. This is the stream-based version of the print function, ideal for processing large receipts or integrating with existing stream pipelines. ### Method `receiptio.createPrint(options)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **options** (string) - Required - A string of command-line options (e.g., `-d `, `-c `, `-p `). ### Request Example ```javascript const fs = require('fs'); const receiptio = require('receiptio'); // Convert receipt file to SVG file using streams const source = fs.createReadStream('receipt.receipt'); const transform = receiptio.createPrint('-p svg -c 48'); const destination = fs.createWriteStream('receipt.svg'); source.pipe(transform).pipe(destination); // Print from file to network printer const input = fs.createReadStream('order.receipt'); const printer = receiptio.createPrint('-d 192.168.192.168 -c 42'); const output = process.stdout; input.pipe(printer).pipe(output); // Convert stdin to PNG file process.stdin .pipe(receiptio.createPrint('-p png -c 42')) .pipe(fs.createWriteStream('receipt.png')); ``` ### Response #### Success Response (200) - **stream** (TransformStream) - A transform stream that accepts receipt markdown and outputs printer commands or converted data. #### Response Example (This method returns a stream, not a direct response value. The output is handled by piping the stream.) ``` -------------------------------- ### POST receiptio.print Source: https://github.com/receiptline/receiptio/blob/main/README.md Converts receipt markdown text into printer commands or images based on the provided options. ```APIDOC ## receiptio.print(markdown[, options]) ### Description Converts receipt markdown text into printer-specific commands or image formats. Supports various printer control languages and output configurations. ### Method Asynchronous function call ### Parameters #### Request Body - **markdown** (string) - Required - The receipt markdown text content. - **options** (object) - Optional - Configuration object for printing: - **d** (string) - Destination (IP address or serial/usb port). - **o** (string) - Output file path. - **q** (string) - Inquire device status (printer, drawer, drawer2). - **c** (number) - Characters per line (24-96, default 48). - **u** (boolean) - Upside down orientation. - **v** (boolean) - Landscape orientation. - **r** (number) - Print resolution for landscape (180, 203). - **s** (boolean) - Paper saving mode. - **n** (boolean) - Disable paper cut. - **m** (string) - Print margin (left,right). - **i** (boolean) - Print as image. - **b** (number) - Image thresholding (0-255). - **g** (number) - Image gamma correction (0.1-10.0). - **t** (number) - Print timeout in seconds. - **l** (string) - Language/Encoding (en, ja, ko, zh-hans, etc.). - **p** (string) - Printer control language (escpos, epson, star, svg, png, etc.). ### Request Example ```javascript const result = await receiptio.print("# Receipt\nItem 1: $10", { p: "epson", c: 48 }); ``` ### Response #### Success Response (0) - **result** (number/buffer) - Returns 0 on success when using -d, or printer commands/image buffer if no destination is specified. #### Error Handling - **100-106** - Printer status codes (online, coveropen, paperempty, error, offline, disconnect, timeout). - **200-201** - Drawer status codes (closed, open). ``` -------------------------------- ### CLI: Print Upside Down with Paper Saving Source: https://context7.com/receiptline/receiptio/llms.txt Print a receipt to a network printer in an upside-down orientation and with paper saving enabled using the '-u' and '-s' flags in the ReceiptIO CLI. ```bash # Print upside down with paper saving receiptio -d 192.168.192.168 -u -s receipt.receipt ``` -------------------------------- ### Transform Stream API Source: https://github.com/receiptline/receiptio/blob/main/README.md This section details the `createPrint` method for creating a transform stream for receipt processing. ```APIDOC ## Transform stream API `receiptio.createPrint()` method is the stream version of the `receiptio.print()`. ```javascript const fs = require('fs'); const receiptio = require('receiptio'); const source = fs.createReadStream('example.receipt'); const transform = receiptio.createPrint('-p svg'); const destination = fs.createWriteStream('example.svg'); source.pipe(transform).pipe(destination); ``` ### Method `receiptio.createPrint([options])` ### Parameters - `options` ### Return value - Transform stream ``` -------------------------------- ### Query Cash Drawer Status Source: https://context7.com/receiptline/receiptio/llms.txt Determine if the cash drawer is open or closed by using receiptio.print() with an empty markdown string and the '-q drawer' option for a specified network printer. ```javascript // Query cash drawer status receiptio.print('', '-d 192.168.192.168 -q drawer').then(status => { console.log(status); // 'drawerclosed' or 'draweropen' }); ``` -------------------------------- ### Convert Receipt Markdown to PNG Image Source: https://context7.com/receiptline/receiptio/llms.txt Generate a PNG image from receipt markdown using receiptio.print() with the '-p png' option. The output is a base64 encoded string that can be saved to a file. ```javascript // Convert to PNG image receiptio.print(markdown, '-p png -c 42').then(pngBase64 => { // PNG image as base64 string require('fs').writeFileSync('receipt.png', pngBase64, 'base64'); }); ``` -------------------------------- ### Query Printer Status Source: https://context7.com/receiptline/receiptio/llms.txt Check the status of a network printer by calling receiptio.print() with an empty markdown string and the '-q printer' option. This returns the printer's current status. ```javascript // Query printer status without printing receiptio.print('', '-d 192.168.192.168 -q printer').then(status => { console.log(status); // 'online', 'coveropen', 'paperempty', 'error', 'offline', or 'disconnect' }); ``` -------------------------------- ### Receipt Markdown Syntax Source: https://context7.com/receiptline/receiptio/llms.txt Formatting rules for receipts, including alignment, tables, barcodes, QR codes, and text styling. ```markdown ^^^RECEIPT # ^^^ = triple height, centered 12/18/2021, 11:22:33 AM # Regular text Asparagus | 1| 1.00 # Table: left | center | right aligned Broccoli | 2| 2.00 Carrot | 3| 3.00 --- # Horizontal rule / separator ^TOTAL | ^6.00 # ^ = double size text {c:1234567890} # Barcode (Code 128) {q:https://example.com} # QR Code {i:base64encodedimage} # Inline image # Text decorations _underlined text_ # Underline "emphasized text" # Bold/emphasized `inverted text` # White on black # Text scaling ^double size # Double width and height ^^triple size # Triple size ^^^quadruple size # Quadruple size # Alignment (at line start) |centered text| # Center aligned |right aligned # Right aligned (single pipe at start) ``` -------------------------------- ### Print Receipt to Network Printer Source: https://context7.com/receiptline/receiptio/llms.txt Use the receiptio.print() API to send markdown receipt data to a network printer. Specify the printer's IP address and character width. ```javascript const receiptio = require('receiptio'); // Example: Print a receipt to a network printer const markdown = `^^^RECEIPT ${new Date().toLocaleString()} Asparagus | 1| 1.00 Broccoli | 2| 2.00 Carrot | 3| 3.00 --- ^TOTAL | ^6.00 {c:1234567890}`; // Print to network printer with 42 characters per line receiptio.print(markdown, '-d 192.168.192.168 -c 42').then(result => { console.log(result); // 'success', 'coveropen', 'paperempty', 'error', 'offline', 'disconnect', or 'timeout' }); ``` -------------------------------- ### Receipt Printing API Source: https://github.com/receiptline/receiptio/blob/main/README.md This section describes the parameters available for printing receipts using the receiptio library. ```APIDOC ## Receipt Printing API ### Description This API allows you to print receipt markdown text to various destinations with customizable options. ### Method POST (Implicit, as it's a library function call) ### Endpoint N/A (This is a library function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters for `receiptio.print()` (or similar function) - `markdown` - receipt markdown text - https://receiptline.github.io/designer/ - `options` - `-d `: ip address or serial/usb port of target printer - Without `-d` option, the destination is the return value - `-q []`: inquire device status without printing - `printer`: printer - `drawer`: cash drawer - `drawer2`: cash drawer with state invert - default: `printer` - `-c `: characters per line - range: `24`-`96` - default: `48` - `-m [][,]`: print margin - range (left): `0`-`24` - range (right): `0`-`24` - default: `0,0` - `-u`: upside down - `-v`: landscape orientation (for `escpos`, `epson`, `sii`, `citizen`, `star`) - `-r `:print resolution for `-v` - values: `180`, `203` - default: `203` - `-s`: paper saving (reduce line spacing) - `-n`: no paper cut - `-i`: print as image (requires puppeteer or sharp) - `-b `: image thresholding - range: `0`-`255` - `-g `: image gamma correction - range: `0.1`-`10.0` - default: `1.0` - `-t `: print timeout (sec) - range: `0`-`3600` - default: `300` - `-l `: language of receipt markdown text - `en`, `fr`, `de`, `es`, `po`, `it`, `ru`, ...: Multilingual (cp437, 852, 858, 866, 1252 characters) - `ja`: Japanese (shiftjis characters) - `ko`: Korean (ksc5601 characters) - `zh-hans`: Simplified Chinese (gb18030 characters) - `zh-hant`: Traditional Chinese (big5 characters) - `th`: Thai - default: system locale - `-p `: printer control language - `escpos`: ESC/POS - `epson`: ESC/POS (Epson) - `sii`: ESC/POS (Seiko Instruments) - `citizen`: ESC/POS (Citizen) - `fit`: ESC/POS (Fujitsu) - `impact`: ESC/POS (TM-U220) - `impactb`: ESC/POS (TM-U220 Font B) - `generic`: ESC/POS (Generic) _Experimental_ - `star`: StarPRNT - `starline`: Star Line Mode - `emustarline`: Command Emulator Star Line Mode - `stargraphic`: Star Graphic Mode - `starimpact`: Star Mode on dot impact printers _Experimental_ - `starimpact2`: Star Mode on dot impact printers (Font 5x9 2P-1) _Experimental_ - `starimpact3`: Star Mode on dot impact printers (Font 5x9 3P-1) _Experimental_ - `svg`: SVG - `png`: PNG (requires puppeteer or sharp) - `txt`: plain text - `text`: plain text - default: auto detection (`epson`, `sii`, `citizen`, `fit`, `impactb`, `generic`, `star`, `svg`, `png`, `txt`) ### Return value - With `-d` option - `success`: printing success - `online`: printer is online - `coveropen`: printer cover is open - `paperempty`: no receipt paper - `error`: printer error (except cover open and paper empty) - `offline`: printer is off or offline - `disconnect`: printer is not connected - `timeout`: print timeout - `drawerclosed`: drawer is closed - `draweropen`: drawer is open - Without `-d` option - printer commands or images ``` -------------------------------- ### Generate Receipt SVG Preview Source: https://context7.com/receiptline/receiptio/llms.txt Generates an SVG representation of the receipt for preview or archival purposes. The output is saved to a file named 'receipt-preview.svg'. ```javascript // Generate SVG for preview/archival receiptio.print(receipt, '-p svg -c 42') .then(svg => { require('fs').writeFileSync('receipt-preview.svg', svg); console.log('Preview saved to receipt-preview.svg'); }); ``` -------------------------------- ### Convert Receipt Markdown to SVG Source: https://context7.com/receiptline/receiptio/llms.txt Convert receipt markdown to an SVG string without sending it to a printer by using the '-p svg' option with receiptio.print(). ```javascript // Convert to SVG (no printer destination) receiptio.print(markdown, '-p svg -c 42').then(svg => { console.log(svg); // SVG string output }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.