Appropriate Sizing of Text Annotations

Discussions about annotation support.
Post Reply
VirDev
Posts: 2
Joined: Wed Oct 16, 2013 5:37 pm

Appropriate Sizing of Text Annotations

Post by VirDev » Wed Oct 16, 2013 11:47 pm

Hello,

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()
Any help would be appreciated.
-Chris

User avatar
Loïc
Site Admin
Posts: 5530
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Appropriate Sizing of Text Annotations

Post by Loïc » Thu Oct 17, 2013 10:25 am

Hello Chris,

We are already working on an autosize feature for the text annotation. The next 10.1 release (that will be published soon) should include it.

With best regards,

Loïc

User avatar
Loïc
Site Admin
Posts: 5530
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Appropriate Sizing of Text Annotations

Post by Loïc » Wed Nov 13, 2013 3:54 pm

Hello,

The new release is available: viewtopic.php?t=4403

To activate the text auto sizing feature just turn the AutoSize property to True (available for AnnotationStickyNote and AnnotationText objects).

Hope this helps!

With best regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest