I have a preprinted sheet, which is missing some data or fields. For example an invoice or a check, with fixed, but empty fields. What I want is to print or fill only the data in the corresponding fields, very accurately. For that it should indicate, somehow, the height and width of the page in millimeters, and the location “x, y” of each field in millimeters.
What is the best way to achieve this?
What i want to achieve is something like this…

Ive done that long time ago (with a Page Layout software).
I took some measures, set my mask in the page, print it once, make adjusts, etc.
After a bunch or prints, it worked fine.
Perfection is out of this word, but we can do correct to good work easily.
On the other hand, you can take measures on the check to where the fields have to be, and use the dpi to get the real (computer) size.
At last, get a scan of the check and
measure where the fields have to be.
For all of these, you can have to deal with 72 dpi (macOS), 96 dpi (Windows), and Retina / HiDPI.
thanks @Emile Schwarz …which software did you use? could that soft be integrated into xojo?
Printing in strings in a graphics object should do it fine. You have to fiddle around a bit to get the borders correctly positioned, but once you have that it is fairly accurate.
thanks @James Pitchford ! I’ll keep it in mind
Today? Draw part of LibreOffice.
Integrated into Xojo ?
No.
Nota: my answer was based on a question for a single document (the bank check).
If you want to be able to do that for “user selected print mask based on multiple document mask” (or doing that for check from a large number of Banks) , this is a different matter.
Think different Emile:
I have a preprinted sheet
I assumed this was a single shot (a single image to print text to), a print mask for one document…
If you want to be ale to let the user build a print mask for any kind of document, you have to provide a way to let him do that la Window Editor in the Xojo IDE.
A few years ago, I wrote some payroll software that had to print out Income Tax information on government supplied preprinted forms. Since you could never guarantee that it would print exactly the same on every possible printer, I added a user adjustable horizontal and vertical offset. The user could do a test print on the form and then adjust the offset values to correct the positioning as necessary. The software would save the value for that particular printer. The offset values were in actual dimensions (inches or millimeters), so that the user could use a ruler to measure exactly how much the print was out of position, and then enter these values as the offset.
I never ran into any problems with scaling, but if the situation arises where the size varies from printer to printer, then you could also include an adjustable scale factor. You also have to make sure that you tell the user not to use the “Scale to fit page” option in the print setup dialog, and always allow for the largest possible non-printable borders that a printer could have.
This is where printing using fixed pitch printer fonts really comes into its own.
a couple of escape codes to set LinePrinter font at 17cpi, and you know that 17 letters is exactly an inch.
Good old days…