Print PDF document directly via PHP or Javascript

Asked

Viewed 2,018 times

1

I wonder if there is a way to print a PDF document directly (without the need to press Ctrl+p in the browser) via PHP or Javascript. For example: create a button that, when clicked, sends the PDF document to the user’s print queue. I’m a beginner in these two languages, so I don’t know if it’s a simple solution question.

  • I found this, I don’t know if it helps: https://stackoverflow.com/questions/19124808/printing-pdfs-from-windows-command-line?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

  • 1

    Just use the event window.print(), for example <button type="button" onclick="window.print()">Imprimir</button>. To choose which elements to print, you can use a specific CSS for printing.

  • You can, for example, in PHP, call Pdftoprinter as follows: system('PDFToPrinter.exe ' . $pdfpath, $result);, Pdftoprinter is on the link above and more easily on this one: http://www.columbia.edu/~em36/pdftoprinter.html

  • 1

    Gave it right @Marcelouchimura, thank you very much!!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.