Display Symbols and Different Fonts in Dynamics NAV 2013 R2
Some weeks ago I came across a requirement to be able to display GD&T symbols in the windows client of NAV 2013 R2 (as part of a quality control system). It sounded easy since the symbols was generated by a string of regular characters displayed with a special font. In the classic client it would just have been to change the font of the text box and it would probably have worked, but it is not that easy in the 2013 version of Dynamics NAV (and I believe the same applies to the NAV 2009 RTC client).
But as always, most of the things can be solved with some creativity. 🙂 Here is an example of how to display different symbols in the windows client of NAV 2013 R2 by using the System.Drawing.Graphics.DrawString method to draw a bitmap with the special font and stream it back into a BLOB field to display it to the user in the client.
For this example we use a GD&T font to generate a GD&T symbol based on a string of characters entered into a text field in Dynamics NAV.
If you are not familiar with GD&T, here is a description from Wikipedia: Geometric Dimensioning and Tolerancing.
We start with adding two fields in the routing quality measurement table, one text field (GDT Text) for the user to type in the text and one BLOB field (GDT Symbol) for the bitmap to be stored. Make sure to set the SubType property of the BLOB field to Bitmap.
Next we add OnValidate code to the ‘GDT Text’ field. The code should draw a bitmap (using System.Drawing.Graphics.DrawString) with the GD&T font and stream it into the ‘GDT Symbol’ field to be displayed to the user. Here is the code.
Note; it might be appropriate to have the font, font size and bitmap size above to come from a setup table instead of being ‘hardcoded’. I would probably do this if this gets implemented.
We add the fields to the page and test it but entering some text into the ‘GDT Text’ field and we see the symbol created in the ‘GDT Symbol’ field. Sweet!! 🙂
Double click on the symbol and it will open in you default picture viewer.
Problem solved! 🙂
Note; it is to be discovered if this works in the web client.