In react shopify admin app, from browser, I can generate and download pdf using html2canvas, jspdf. But when I do the same thing in shopify POS app, it doesn’t work.
Sample code I used like below.
const result = handleValidation();
if (result.show === true && result.message != "") {
setToastData({
show: true,
isError: true,
message: result.message,
});
return;
}
const capture = document.querySelector(".pdf-body-in-html");
const dpi = 300;
const scale = dpi / 96;
html2canvas(capture, { scale: scale }).then((canvas) => {
const imgData = canvas.toDataURL("img/png");
const doc = new jsPDF("p", "mm", "a4");
const componentWidth = doc.internal.pageSize.getWidth();
const componentHeight = doc.internal.pageSize.getHeight();
doc.addImage(imgData, "PNG", 0, 0, componentWidth, componentHeight);
doc.save("receipt.pdf");
});
I also tried other library like pdf-lib which worked for web app, but same result for POS app. Is there any configuration for POS app to generate and download pdf files