I'm trying to print a pdf file from a URL.
what I have done so far:
fetch(
"https://media.readthedocs.org/pdf/flask-cors/latest/flask-cors.pdf"
)
.then(function (response) {
return response.blob();
})
.then((data) => {
const localPdf = window.URL.createObjectURL(data);
const printFrame = document.getElementById("pdf");
printFrame.setAttribute("src", localPdf);
printFrame.onload = () => {
printFrame.focus();
printFrame.contentWindow.print();
};
});
<iframe id="pdf" name="pdf" />
It works without any problem. BUT in the chrome browser there is an option in chrome://settings/content/pdfDocuments
when Download PDF files instead of automatically opening them in Chrome
is active I got this error :
SecurityError: Blocked a frame with origin "https://localhost:44310" from accessing a cross-origin frame.
I got this error even when the file is in the same origin.
I didn't find any solution. Is there any other way to print a file?