Answer the question
In order to leave comments, you need to log in
How to print a small receipt using a receipt printer from a browser?
Hello. Need advice on combining a receipt printer with a browser.
There is a Mercury MPRINT G58 receipt printer.
I have a php+js web application.
A window with inscriptions is formed in the application, which is sent for printing to a receipt printer using a browser. Currently using chrome. The type of browser does not matter, you can switch to any.
Problem: The printer prints a very long receipt, regardless of the number of labels. That is, suppose we have 5 lines that fit on 3-4 cm of paper, but the printer continues to print a receipt. Printing stops after a while, but the receipt is very large. Presumably, the printer is trying to print the entire A4 page, only in receipt format, which is why paper of this length comes out.
Q: Is it possible to limit print time/paper length? Or, perhaps, if someone has already encountered a similar problem, then what can be done in this case?
Answer the question
In order to leave comments, you need to log in
Solution of the problem:
@media print {
@page {
size: 50mm 150mm; /*set any size you want*/
}
}
There are CSS rules for printing, you can try to add the following code for the printed page:
@page {
size: 3in 3in;
margin: 0;
}
@media print {
html, body {
width: 3in;
height: 3in;
}
}
when manually printing, there is an option "page settings" where the sizes are set (more margins, and something else there on the little things) - this should be enough to check your version
if the print job is generated programmatically, there must be some kind of api. the keyword is still the same "page settings"
ps By the way, if the printer was purchased officially, can you contact the manufacturer directly?
service.mercury-equipment.ru/?p=866
look aside @media print
, I remember there was a property to indicate the page size when printing
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question