Answer the question
In order to leave comments, you need to log in
How do browsers calculate media print width in pixels?
Typesetting html with sizes in pt is not suitable.
Need 1/203 inch accuracy.
The only hope for px, but it is not clear with them, it seems that everyone thinks in their own way.
in the question, PX is a unit, the size of the smallest dot that can be drawn
. The logical assumption that the px size for printing would be 1/75 is not supported. Browsers consider
that A4 in width is something from 7xx to 8xx.
What I want is that the
layout on the printer, on the phone screen and on the computer is the same, not in physical dimensions, but in appearance (
number of letters per line and, for example, in a table cell)
In Android, canvas resolution 1pt = 1/72 inch.
Those. if we just put Point() it will be 1/72 by 1/72
The thermal printer only has 384 dots per line. The actual density is 1/203.
If we describe the media with actual density, then existing
programs will draw only 137 pixels
, resulting in sharp printing at 1/3 of the width, or blurring at the full width.
The best result is obtained when the roll is described at 72dpi and 1/2 inch margins.
Unit of measure is millis 1/1000 of an inch field
formula calculation
+ 1000 * dots_in_the_printer_matrix / 72
1000 + 1000 * 384 / 72 is converted to type integer . Alas, we lose a few points for rounding.
why not a constant, so in addition to 384, there is also 560 and in general the manufacturer can produce
a model with any number of points (a multiple of 8, if he is not a complete pervert)
This description as a result allows you to print at full resolution. There are very few points and they should all work.
Drawing by means of android becomes simple, the only amendment
is 1pt = 1dot
I took the dimensions from the canvas and you know how many points are available to you.
But how to make the WebView understand correctly?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question