Sunday, 15 January 2012

c# - Measure String in MigraDoc TextFrame -



c# - Measure String in MigraDoc TextFrame -

i've tried asking question on forums yet have received response, hope can help me on here.

i have setup custom study screen in asp.net people can drag labels , fields , migradoc produces accordingly using textframes , top/left/width/height properties lay them out in same place dragged/resized to. works great 1 issue have if text longer textframe runs off page , need page move on accordingly whilst retaining other objects in place.

i can utilize below code measure string:

style style = document.styles["normal"]; textmeasurement tm = new textmeasurement(style.font.clone()); float fh = tm.measurestring(value, unittype.millimeter).height; float fw = tm.measurestring(value, unittype.millimeter).width;

but it's useful comparing width against frame , not height because different 1 time set smaller area. know how can measure string based on bound width/height values i.e. within text frame.

look @ createblocks() method in xtextformatter class , how calls measurestring in loop break text multiple lines.

i'm afraid have implement such loop yourself.

or maybe utilize preparedocument() method of documentrenderer class allow migradoc work , query dimensions when it's done.

btw: similar question had been asked @ forum before: http://forum.pdfsharp.net/viewtopic.php?p=3590#p3590 reply includes source code.

c# asp.net migradoc

No comments:

Post a Comment