T
T
Tash1moto2016-06-25 10:55:09
JavaScript
Tash1moto, 2016-06-25 10:55:09

How to print a sales receipt in javascript?

Hi all.
There was a task that I had never encountered, namely, to implement a convenient receipt printing from a web application.
Receipt printer HPRT TP806 www.hprt.com/Product/POS-Printer/TP806.html
Ideas:
1. Generate a PDF on the server and transfer it to the client, then download it to a computer and print it as a file.
2. Generate a check immediately in the browser, open it in a new page, then window.print() and press print. there is a problem, if I'm not mistaken, you can print only A4
Can you tell me the best way?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Peter, 2016-06-25
@petermzg

Open in new page for which css

@page {
  size: A4;
  margin: 0;
}
@media print {
  html, body {
    width: 210mm;
    height: 297mm;
  }
}

Specify the desired page dimensions

S
sim3x, 2016-06-25
@sim3x

The problem here is mmm, trust in the cashier
. In general, you can’t allow printing from the browser interface .
Therefore, we write a service that will hang on the cashier’s PC and listen to port, for example 1337 what you need to print a check The button leads to the port (let's say 127.0.0.1:1337/check_id=1234) that listens to your software, which is connected to the printer The software goes to the site and takes the check with id 1234 from there Prints AND sends the print log to the djanga PS: when the site / Internet is disabled, the scheme will not work

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question