DEV Community

Srinivasan Govindaswamy
Srinivasan Govindaswamy

Posted on

print pdf in iPad safari / chrome using pdfmake

Hello All,

I am trying to show dynamically generated pdf in an iFrame. It works fine in desktop browsers. In safari iPad it is showing only first page in the iFrame. Looks like URL.createObjectURL(blob) is getting only the first page. Below is the code. Appreciate your help.

pdfMake.createPdf(dataInput).getBlob((blob) => {
const blobURL = URL.createObjectURL(blob);
const targetElement =
document.querySelector("#iframeContainer");
const iframe = document.createElement("iframe");
iframe.src = blobURL;
iframe.id = "printIframe";
targetElement?.appendChild(iframe);
iframe.onload = function () {
if (iframe && iframe.contentWindow) {
iframe.contentWindow.print();
}
};
});

Top comments (0)