Printing directly to the printer

1

I have a system of passwords where the user clicks a button and a password is printed for it. I needed the impression to be direct, because using js window.print() a dialog box opens. How to resolve this in PHP 7?

    
asked by anonymous 01.12.2018 / 11:33

1 answer

0

As Anderson said, in PHP you do not have this control because it does not work in the browser, only on the server, so the most you could do is the browser send a request to PHP on the server to ask for the impression and it sends it to the printer, so the printer must be connected to the server or be a networked printer.

And this is even more interesting. One thing I always say, but almost every beginner (some with many years of experience, but those who do not learn are still new) ignores is that there are certain tools for each task. It has a task that does not matter much use the wrong, or at least the damage is not so visible (which is even worse since the person thinks it is good), and any software that is not used sporadically by someone, other than for external use of people on computers outside the organization of that software should never run in a browser. Browsers were created for simple and quick access that does not require installation. It brings huge losses to constant use, it was not created to replace the desktop as many think.

Iimaginethatpeopletrytodoitthiswaybecausetheydonotknowanddonotwanttoknowothertechnologiesmoresuitableforthetask.Butthisisgambiarrabydefinition.Userinteractioninbrowsersisgreatlyimpaired,andlimited.

SoevenhavingabrowseronlyavailableforausertoaskforapasswordandletPHPprintiscompletelymeaningless,crappyUXandevenunsafe.

HavingawebserverjusttodealwiththisandmakingtheimpressionislikegoingfromRiotoSãoPaulothroughBrasiliabefore.Itismuchsimplertodothiswithanothertechnologydirectlyonthecomputerthatwillhandlethepassword,somethingthathasbetterusabilityandiseasiertocontrolaccess.

Ifyouarenotabletodothisasksomeoneelsetodoit.AndIhopetherestoftheinternalsystemsfollowthesamepath.

Ifyouinsistontheerror(andIhopeyouatleasthavetheethicsoftellingpeoplethatyouhirethemthatthisisamistake),itwilloperatelikeanywebapplication,sinceitisone,andusetheclientinthebrowseronlyastheinteractionwiththeuseranddelegatetotheservertomaketheimpression.Herethemostcommonistouse printer_open() , but some people use specific features of the server ( print , lp , etc.), or send it to a special operating system file as prn , lpt1 or something like this. Others use fsockopen() , but I've seen more exotic solutions.

I replied, but I'm sorry for that, it's like giving a chainsaw to a child.

    
01.12.2018 / 13:54