Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 34 additions & 5 deletions apps/OpenSign/src/constant/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
import Parse from "parse";
import { appInfo } from "./appinfo";
import { saveAs } from "file-saver";
import printModule from "print-js";
import fontkit from "@pdf-lib/fontkit";
import { SCALE_STEPS, themeColor } from "./const";
import { format, toZonedTime } from "date-fns-tz";
Expand Down Expand Up @@ -3037,7 +3036,7 @@ export const handleDownloadPdf = async (
await fetchUrl(url, docName);
setIsDownloading && setIsDownloading("");
} catch (err) {
console.log("err in getsignedurl", err);
console.error("err in getsignedurl", err);
setIsDownloading("");
alert(i18n.t("something-went-wrong-mssg"));
}
Expand Down Expand Up @@ -3090,13 +3089,43 @@ export const handleToPrint = async (event, setIsDownloading, pdfDetails) => {
const blobUrl = URL.createObjectURL(blob);
window.open(blobUrl, "_blank");
setIsDownloading("");
} else {
printModule({ printable: pdf, type: "pdf", base64: true });
}
else {
const response = await fetch(url);

if (!response.ok) {
throw new Error(`Failed to fetch PDF: ${response.status}`);
}

const blob = await response.blob();

const blobUrl = URL.createObjectURL(blob);

const iframe = document.createElement("iframe");

iframe.style.position = "fixed";
iframe.style.right = "0";
iframe.style.bottom = "0";
iframe.style.width = "0";
iframe.style.height = "0";
iframe.style.border = "0";

iframe.src = blobUrl;

document.body.appendChild(iframe);

iframe.onload = () => {
setTimeout(() => {
iframe.contentWindow.focus();
iframe.contentWindow.print();
}, 1000);
};

setIsDownloading("");
}
} catch (err) {
setIsDownloading("");
console.log("err in getsignedurl", err);
console.error("err in getsignedurl", err);
alert(i18n.t("something-went-wrong-mssg"));
}
};
Expand Down