A
A
Anton2012-08-07 11:50:56
.NET
Anton, 2012-08-07 11:50:56

How can I find out the exact length of the printed text?

Good day ...
There is a Zebra p430i card printer, a .NET program that should print on it and a problem with text alignment, which is as follows:
there are several texts right-aligned in the area from 10 to 50 mm, the texts are printed in different styles and fonts, while the right edges of the texts should be at the same level, but in reality there is an offset from a millimeter to 2, depending on the fonts and styles ... I tried to align both using the printer and the Graphics object created from the graphics context of the printer, the results are zero ... And, accordingly, the question is whether it is possible to somehow find out the exact dimensions of the line that will be printed in order to make corrections when printing, or how - to align the text pixel by pixel? At the same time, it is advisable not to go into the wilds of fonts ... I have already tried options with MeasureString and MeasureCharacterRanges, the size is only approximate ...

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey Polyakov, 2012-08-07
@magnitudo

Are you sure you're doing everything right? I somehow solved a similar problem and there were no such problems. Try drawing the layout on the form/panel and see if the offset remains?
If yes, then the matter is probably in the features of the fonts, in this case you can try to manually find the indent of the text relative to the left edge and adjust the position.
If not, then look at the parameters of hinting and all sorts of printer enhancers.

A
Anatoly, 2012-08-07
@taliban

In fact, a lot depends on the fonts, monospace fonts, for example, in addition to the letter itself, they also take into account the gap in the width calculations, that is, the same point will have the width of the letter w, and there is no getting around it =)

M
MikhailEdoshin, 2012-08-07
@MikhailEdoshin

And if you print a geometric figure of a given size, does it come out as specified, or does it float?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question