We help IT Professionals succeed at work.

Calculate width of printed text  in mm (if possible)

peispud
peispud asked
on
High Priority
28 Views
Last Modified: 2020-03-23
Hi

I am using Microsoft Access.  I am using a SDK to print directly to a Brother labeller  (one of 3 templates)

In this case, the label will only have one field.   My code will populate that field.

In order for my app to choose the appropriate  label template,  I must first calculate the printed width of my data and then choose the appropriate template.

So, how do I calculate the width of that printed text in mm (if possible) ?

ps.  I know that  many of you are helping others,  just because..       I hope your good Karma comes back to you and your loved ones in these difficult times.
Comment
Watch Question

John TsioumprisSoftware & Systems Engineer
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Maybe there isn't a Windows label template that matches your label.
Just measure your label (your provider should have supplied the exact dimensions but just in case)
Go to Control Panel --> Devices and Printers -->JUST Single Click one of your Printers -->"Print Server Properties" should become visible on the top --> Create a New Form --> Enter the exact dimensions of your label....BEFORE you enter the numbers consult your Brother labeller...it probably has an empty space (margin/gap whatever ...it would be some mms) ...enter this to the "Printer Area margins"..give your label a name.
Now head to Access...open your report...page setup...select the Brother...select the label (the name YOU gave)...now just tweak the report to match the label dimensions...just keep getting it shorter/narrower till the green overprint indicator turns off
CERTIFIED EXPERT
Commented:
Sorry I didnt read well, you are not printing barcodes, just text, it all gets easier, just get your font size by number of chars for aproximate width, this  will not work with proportional spaced characters since letter "I" takes less space than the letter "O", but you will get aproximations, I am removing all the nonsense about barcodes Iin this commanet, and sorry again.

if using .NET you  can call graphics object's MeasureString method from the Graphics class
and PrintDocument.PrintPage event
it will return the printed length
you pass it the font, the string, and set some properties (Graphics.PageUnit Property) to specify the unit of measure to use (mm in your case)
system.drawing.graphics.measurestring
peispudTech

Author

Commented:
Thank you for your help.  

The question was correctly answered,  Thank you.


But my question should have been

Is it possible to make the printed label size changeable depending on the text length?


The FAQ shown below was exactly what I was looking for.  There the question is answered.

https://www.brother.co.jp/eng/dev/bpac/faq/index.aspx