To send a PDF file directly to the printer using JavaScript, we create an object URL.
For instance, we write
const dataUrl = window.URL.createObjectURL(file);
const pdfWindow = window.open(dataUrl);
pdfWindow.print();
to call createObjectURL
with the PDF file
to create the PDF file object URL string.
Then we open the dataUrl
in a window wiith window.open
.
Finally, we call print
to open the print dialog to print the PDF.
Top comments (0)