Collections of javascript and react utilities to handle the Dymo LabelWriter web service.
npm install --save react-dymo-hooks
or
yarn add react-dymo-hooks
printLabel()
Print Dymo labels
useDymoCheckService()
Return the status of DYMO Label Web Service
"initial" | "loading" | "success" | "error"
Status of DYMO Label Web Service.useDymoFetchPrinters()
Returns the available DYMO Labelwriter Printer
useDymoCheckService()
hook)Object containing:
"initial" | "loading" | "success" | "error"
Status of loading printers.useDymoOpenLabel()
Render Label
useDymoCheckService()
hook)Object containing:
"initial" | "loading" | "success" | "error"
Status of open label.Inside the root directory project
example/
yarn install
or npm install
yarn run start
or npm run-script start
import {printLabel} from "react-dymo-hooks";
async function handlePrintSingleLabel(printerName, labelXml) {
try {
const response = await printLabel(printerName, labelXml);
console.info(response);
} catch (error) {
console.error(error);
}
}
<button onClick={() => handlePrintLabel(printer, xml)} />;
import {useDymoOpenLabel, useDymoCheckService} from "react-dymo-hooks";
const DymoLabelPreview = () => {
const statusDymoService = useDymoCheckService();
const {label, statusOpenLabel, errorOpenLabel} = useDymoOpenLabel(statusDymoService, xmlFile);
if (label) {
return <img src={"data:image/png;base64," + label} alt="dymo label preview" />;
} else {
return null;
}
};
MIT © apenab