Direct Print
Direct Print
Lidta Direct Print lets your application send HTML receipts, invoices, labels, and documents directly to the user's local printers.
Developers only need the lidta-drp JavaScript SDK. The SDK lets you:
- Check whether Direct Print is ready.
- Get available printers.
- Read and save printer settings.
- Send HTML to one or more printers.
Requirements
Before integrating, make sure the user has:
- A Lidta Direct Print plan. A free plan for one device is available.
- The Lidta desktop app installed, signed in, and running with Direct Print showing
ACTIVE. - The Lidta browser extension installed and enabled.
- At least one printer installed on their computer.
See the plans on the Direct Printing page.
Install The Desktop App
Download and install the desktop app for your platform:
Each link always gives the newest version. The Direct Printing page shows what is available for each system.
After installation, sign in with your Lidta account or activate Direct Print with your access key.

The app does not need to stay open on screen. It only needs to be running. It can keep running from the system tray while users continue working in the browser.

Install The Browser Extension
Install the extension from the browser store.
Store Links
Install The SDK
Use npm:
npm install lidta-drp
Or load the browser bundle:
<script src="https://cdn.jsdelivr.net/npm/lidta-drp/dist/lidta-drp.umd.js"></script>
Quick Start
import { waitUntilReady, getPrinters, printHtml } from 'lidta-drp';
await waitUntilReady();
const printers = await getPrinters();
await printHtml({
html: '<h1>Receipt #123</h1><p>Thank you.</p>',
printers: [printers[0].name]
});
Browser bundle example:
<script src="https://cdn.jsdelivr.net/npm/lidta-drp/dist/lidta-drp.umd.js"></script>
<script>
async function printReceipt() {
await LidtaDrp.waitUntilReady();
const printers = await LidtaDrp.getPrinters();
await LidtaDrp.printHtml({
html: '<h1>Receipt #123</h1><p>Thank you.</p>',
printers: [printers[0].name]
});
}
</script>
What Data You Need
To print, your app needs:
| Data | Example | How To Get It |
|---|---|---|
html | '<h1>Receipt</h1>' | Build this from your app's receipt, invoice, or label template. |
printers | ['POS-80'] | Call getPrinters() and use the printer name. |
To save printer settings, your app needs a PrinterInfo object returned by getPrinters() or getPrinterConfig(name).
Get Available Printers
import { getPrinters } from 'lidta-drp';
const printers = await getPrinters();
console.log(printers);
Example response:
[
{
"name": "POS-80",
"displayName": "Front Counter Printer",
"status": "Idle",
"description": "Thermal receipt printer",
"is_default": true,
"options": {
"width": "80",
"height": "297",
"zoom": "1",
"margin_top": "0",
"margin_bottom": "0",
"margin_left": "0",
"margin_right": "0",
"orientation": "Portrait",
"copies": "1"
}
}
]
Use printer.name when sending print jobs.

Print HTML
import { printHtml } from 'lidta-drp';
await printHtml({
html: document.getElementById('receipt').innerHTML,
printers: ['POS-80']
});
You can print to multiple printers:
await printHtml({
html: '<h1>Kitchen Order</h1>',
printers: ['Kitchen Printer', 'Cashier Printer']
});
You can also pass printer objects returned by getPrinters():
const printers = await getPrinters();
await printHtml({
html: '<h1>Receipt</h1>',
printers: [printers[0]]
});
Printer Settings
The SDK returns printer settings inside each printer's options field.
interface PrinterInfo {
name: string;
displayName: string;
status?: string;
description?: string;
is_default?: boolean;
options: {
width: string;
height: string;
zoom: string;
margin_top: string;
margin_bottom: string;
margin_left: string;
margin_right: string;
orientation: 'Portrait' | 'Landscape';
copies: string;
};
}
All option values are strings. Dimensions and margins are in millimeters.
Get One Printer Configuration
import { getPrinterConfig } from 'lidta-drp';
const printer = await getPrinterConfig('POS-80');
Save Printer Configuration
import { getPrinterConfig, savePrinterConfig } from 'lidta-drp';
const printer = await getPrinterConfig('POS-80');
printer.displayName = 'Front Counter Printer';
printer.options.width = '80';
printer.options.height = '297';
printer.options.zoom = '1';
printer.options.margin_top = '0';
printer.options.margin_bottom = '0';
printer.options.margin_left = '0';
printer.options.margin_right = '0';
printer.options.orientation = 'Portrait';
printer.options.copies = '1';
await savePrinterConfig(printer);
Validation rules:
nameis required.width,height, andzoommust be greater than0.- Margins must be
0or greater. zoommust be between0.1and5.copiesmust be between1and100.orientationmust bePortraitorLandscape.
SDK Methods
| Method | Returns | Description |
|---|---|---|
waitUntilReady(timeoutMs?) | Promise<ReadyResponse> | Checks if Direct Print is ready. |
isReady(timeoutMs?) | Promise<boolean> | Returns true or false. |
getPrinters(timeoutMs?) | Promise<PrinterInfo[]> | Gets available printers. |
getPrinterConfig(name, timeoutMs?) | Promise<PrinterInfo> | Gets one printer's settings. |
getAllPrinterConfigs(timeoutMs?) | Promise<PrinterInfo[]> | Gets all printer settings. |
savePrinterConfig(printer, timeoutMs?) | Promise<SavePrinterConfigResponse> | Saves printer settings. |
printHtml(input) | Promise<PrintResponse> | Sends HTML to printers. |
enableDebug() | () => void | Logs SDK responses during development. |
Vue 3 Example
<script setup>
import { onMounted, ref } from 'vue';
import { getPrinters, printHtml, waitUntilReady } from 'lidta-drp';
const printers = ref([]);
const selectedPrinter = ref('');
const receiptRef = ref(null);
const isPrinting = ref(false);
onMounted(async () => {
await waitUntilReady();
printers.value = await getPrinters();
selectedPrinter.value = printers.value[0]?.name || '';
});
async function printReceipt() {
if (!receiptRef.value || !selectedPrinter.value) return;
isPrinting.value = true;
try {
await printHtml({
html: receiptRef.value.innerHTML,
printers: [selectedPrinter.value]
});
} finally {
isPrinting.value = false;
}
}
</script>
<template>
<select v-model="selectedPrinter">
<option v-for="printer in printers" :key="printer.name" :value="printer.name">
{{ printer.displayName || printer.name }}
</option>
</select>
<div ref="receiptRef">
<h2>Order Receipt</h2>
<p>Order #: 123456</p>
<p>Total: $42.99</p>
</div>
<button :disabled="isPrinting || !selectedPrinter" @click="printReceipt">
{{ isPrinting ? 'Printing...' : 'Print Order' }}
</button>
</template>
React Example
import { useEffect, useRef, useState } from 'react';
import { getPrinters, printHtml, waitUntilReady } from 'lidta-drp';
export default function PrintReceipt() {
const receiptRef = useRef(null);
const [printers, setPrinters] = useState([]);
const [selectedPrinter, setSelectedPrinter] = useState('');
const [isPrinting, setIsPrinting] = useState(false);
useEffect(() => {
async function loadPrinters() {
await waitUntilReady();
const available = await getPrinters();
setPrinters(available);
setSelectedPrinter(available[0]?.name || '');
}
loadPrinters().catch(console.error);
}, []);
async function printReceipt() {
if (!receiptRef.current || !selectedPrinter) return;
setIsPrinting(true);
try {
await printHtml({
html: receiptRef.current.innerHTML,
printers: [selectedPrinter]
});
} finally {
setIsPrinting(false);
}
}
return (
<>
<select value={selectedPrinter} onChange={(event) => setSelectedPrinter(event.target.value)}>
{printers.map((printer) => (
<option key={printer.name} value={printer.name}>
{printer.displayName || printer.name}
</option>
))}
</select>
<div ref={receiptRef}>
<h2>Order Receipt</h2>
<p>Order #: 123456</p>
<p>Total: $42.99</p>
</div>
<button disabled={isPrinting || !selectedPrinter} onClick={printReceipt}>
{isPrinting ? 'Printing...' : 'Print Order'}
</button>
</>
);
}
Error Handling
SDK calls reject with an error when the action fails.
try {
await printHtml({
html: '<h1>Receipt</h1>',
printers: ['POS-80']
});
} catch (error) {
console.error(error.code, error.message);
}
Common error codes:
| Code | Meaning |
|---|---|
EXTENSION_UNAVAILABLE | The user needs to install or enable the Lidta browser extension. |
APP_NOT_READY | The user needs to start or activate the Lidta desktop app. |
INVALID_ARGUMENT | Required HTML or printer data is missing. |
INVALID_CONFIG | Printer settings failed validation. |
PRINTER_NOT_FOUND | The selected printer name was not found. |
PRINT_FAILED | The print job could not be completed. |
TIMEOUT | No response arrived before the timeout. |
Troubleshooting Checklist
If printing does not work, ask the user to check:
- The Lidta desktop app is running and Direct Print shows
ACTIVE. - The Lidta browser extension is installed and enabled.
- The selected printer exists in
getPrinters(). - The printer is online and can print normally from the computer.
- The browser tab was refreshed after installing or updating the extension.
