I´m making a simple webapp, I want that when it is open in mobile phones print some data using the user´s wifi printer which most of cases will be an Epson L355.
Can anybody give me a clue or sample to achieve this?
Thank you all.
You won't be able to do this because you don't have access to the user's printer. Instead, you can just generate a pdf and redirect user on it.
The user will then be able to download / print the pdf via his inline PDF viewer.
You can do it by following this :
How to force files to open in browser instead of download (pdf)?
Related
So, I have this application in Symfony, I use a printer for some stickers, which is fine using JS window.print(), but now, I need to print PDFs and I cannot ask the user to do anything.
Is it possible to directly send the PDF to the printer either from PHP or JS?
I can setup a local server which will be connected on the same network with the printer.
I cannot find nothing about directly printing except some PHP 4.0.4 version extension.
I'm using Symfony 4 with PHP 7.3 and JS for the front end stuff.
Can you please advise if there is a library for PHP or I can skip the print button on window.print() in JS.
Thanks in advance
Directly this shouldn´t be possible, but what if your Printer has got a smb-hotfolder functionality? Then you could write out files into this hotfolder. Regards
Is there any JS solution to download the PDF generated by window.print() ? I need not to open the print window, but simply download the PDF.
I have tried other plugins but the PDF generated by window.print() is the exact thing I needed.
Any ideas how to achieve the same?
i think window.print() function gives pop-up to print your html page..noting more, one alternative solution is you can use jsPDF library to generate pdf.
https://parall.ax/products/jspdf
window.print() invokes the print dialog or printing process of the browser. Depending on the device, it either physically print a paper or write the output to a PDF printer.
Both these actions happen in the client side and the printout or the PDF is already with the client as of the end of printing.
There is nothing to be "downloaded" as a result of this.
-
And to select the PDF printer directly without seeing the print dialog, mostly a user action is needed. JS has no method to replace this user action.
--
There are some libraries which can turn your web page in to a PDF and let you download it. But none of them are as perfect as the browser default printing.
There are some server side solutions available. Those can generate the PDF with 99.9% perfection and send the result to the front end for you to downlaod.
Please see DOMPDF
i'm developing a Ruby on Rails application and i trying to print a PDF in silent mode, in the words, after user press print dialog confirmation, the application get the default printer and send it.
One of my options, is create a Google Chrome extension, that user can manage the printer and size of paper and etc, only once. And all time that user want to print a PDF the extension send it silently to the default printer.
So, how can i do this extension?
There's any way to manage user print config with js?
There are a better way to do that?
Thanks.
I have an app that generates PDFs and I want it to be able to print the PDF to the client default printer. How can I accomplish that?
Thanks
Edit: Javascript link could also work.
You could embed javascript in your pdf.
http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/Acro6JSGuide.pdf
So when you generate the PDF, use this.print() when the document is opened.
Rails only sends the PDF to the browser, and the browser/user handles printing. You really can't control what printer it gets sent to...
I need to set up a print button in HTML that will print a certain PDF file, hopefully without having to download the file first. I've tried a few things but some only work in IE. and some require downloading the file as an embedded object which also is not acceptable. Embedding javascript in the PDF sounds the most promising, but I'd rather avoid that if possible for other reasons.
Any other ideas?
Unfortunately it really can't be done... PDFs are not handled naively by any browser, and as is such they can't be printed using the browser's print dialog.
Your users will have to download the pdf and print it with whatever PDF software they use (Even if it's just a plugin for the browser) unless you convert it to boring old html or an image or something.
You cannot print something without the user downloading it first.
The printer is located on the user end of the connection. The PDF is, at first, located on the server end.
The PDF must thus travel across the webs to reach the user end before the printer will know which ink to put on paper. In other words, it must be downloaded.
I think the best you can do is download the PDF into an iframe element, and advise the user to click the "print" button in there. To my knowledge, no tighter integration than that is possible. The PDF viewer's print button can not be accessed via JavaScript.