AX2009 Report String Field Font Properties

Good afternoon,

I am generating a bunch of AX Reports which are product labels to be printed in our production environment. One of the issues that we have is that our part numbers vary massively in length, so I am trying to (by code) create a method to automatically change the font size to fit a specified string field size.

For example, in the report, I will create a string field with auto width and height set, and a font size of 72. Then in the ExecuteSection method, I will call my own method, passing the name of the field and the width and height that I would like to constrain it to.

Where I’m struggling is that some of the methods that I believe I need to use do not seem to have any documentation within AX or Technet, and I’m wondering if anyone is able to shed any light on what the values they return are.

The methods are all part of the ReportStringControl class (which is extended from ReportControl).

The methods are:

fontInfoPrinter()

fontInfoPrinterAscent()

fontInfoPrinterDescent()

fontInfoPrinterExtLead()

fontInfoPrinterHeight()

fontInfoPrinterIntLead()

If anyone is able to explain what these methods do, or even point me to some documentation on them, I would be very grateful. I’m hoping that one of them will allow me to measure the width of a string of a specified font and font size, similar to the FontMetrics class in Java.

Thanks in advance.

I have subsequently found the answer to this.

This article explains what they mean:

http://flylib.com/books/en/3.217.1.179/1/

I have also solved the problem using the following code, on the off chance that anyone finds this article and wants to know. Maybe someone can feedback with a more graceful solution than using a while loop.

void autoResize(ReportStringControl _obj, real _size)

{

;

while (_obj.width100mm() > (_size *100))

{

_obj.fontSize(_obj.fontSize()-1);

}

}