B
B
BurBurunduk2018-09-10 11:13:14
Google Chrome
BurBurunduk, 2018-09-10 11:13:14

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

4 answer(s)
B
BurBurunduk, 2018-09-10
@BurBurunduk

Solution of the problem:

@media print {
    @page {
        size: 50mm 150mm; /*set any size you want*/
    }
}

Thanks to everyone for their help, especially synapse_people and AngReload (in my case, their suggestions helped me get to the right code).

A
AngReload, 2018-09-10
@AngReload

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;
  }
}

https://developer.mozilla.org/en-US/docs/Web/CSS/@...

#
#, 2018-09-10
@mindtester

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

S
synapse_people, 2018-09-10
@synapse_people

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 question

Ask a Question

731 491 924 answers to any question