We have begun evaluating GdPicture as a candidate to replace our current imaging SDK, with which we have become unsatisfied.
Most of the functionality we use is straightforward and the GdPicture function calls can be swapped in very easily. However, we are having trouble with one area and hope you can help.
Our application stores annotations in a database, and when a document is loaded, the annotations are pulled from the database and rendered at run-time for the user. Our problem is with Text Annotations in particular. The Text Annotations we need to render are of multiple length, and the GdPicture function to draw a Text Annotation requires width and length parameters. In our current control, we use the .NET MeasureString() function to determine the length of the string that is to be rendered. When we do this with GdPicture the results are always incorrect. We have tried converting the coordinates using the CoordViewerToDocument and CoordDocumentToViewer functions but those don't give us the correct results either.
What we are looking for is a way to draw a Text Annotation for variable length strings at run-time and each Text Annotation be precisely sized to fit the length of the text.
Here is some very simple test code that shows our problem:
Code: Select all
' Load a file in the GdPicture viewer (v) v.DisplayFromFile("C:\temp\test.tif") ' Create an annotation manager Dim am As New GdPicture9.AnnotationManager am.InitFromGdViewer(v) am.SelectPage(v.CurrentPage) ' Here is the way our current image control would obtain the length of the Text Annotation ' But this does not seem to work for GdPicture Dim TextToRender As String = "Test String to Draw" Dim TextToRenderFont As New Font("Arial", 12) Dim sf As SizeF = v.CreateGraphics.MeasureString(TextToRender, TextToRenderFont) ' Create a Text Annotation ' Here is where the problem occurs, we are trying to find the appropriate length and width values that will ' be precisely the size of the text that is displayed Dim ex As GdPicture9.AnnotationText = am.AddTextAnnot(1, 1, ???, ???, TextToRender) ex.FontName = "Arial" ex.FontSize = 12 ex.FontStyle = FontStyle.Regular ' Draw the annotations on the screen am.SaveAnnotationsToPage() am.Close() v.ReloadAnnotations() v.Redraw()