distancespacesdot-matrix

How to preserve data alignment in dot matrix printing no matter the character size (pitch)


I print text into a dot matrix printer using the generic text only driver and I manage to align data on paper's columns using one space character for every empty printing character on the 135 characters wide paper. This works on 10CPI in the sense that data is at the columns where they should be but not if user selects other character size like 17CPI for example. On the latter case alignment is preserved but data do not sit in the expected place. For instance a character that is supposed to be in place 120 on the line (the 120th character),while on 10CPI it prints indeed there, towards the end of the line, on 17CPI it prints in the middle of the paper.

I understand that this happens because the actual space characters that I use between columns is smaller on 17CPI.

So, my questions are:

1) should I go ahead and use more than one space character whenever the pitch is greater than 10CPI? I could test on that but it seems not a good practise. Or should I try to use absolute horizontal position with the appropriate esc commands? Yet, this is not recommended according to the escp2 manual.

2) should I send \r\n inside the string that I send to the printer for each line of data or should I send just the line of data and at the end of it the escp2 command CR?

Thanks in advance.


Solution

  • 1) well I concluded that one cannot actually build an array that will fit the page no matter the character pitch (CPI) that the end user selects. This refers to pre-printed fanfold paper. Once the user decides to change CPI then they ought to reconfigure the positions of the text inside each line, which means they need to reconfigure the columns distance. I give the user such a capability by providing line number and position within that line for each text that I am going to print, on a settings section.

    2) I end up doing the second. I create a two-dimensional array and send each line followed by a CR and an LF escp command.