ThinkGeo.com    |     Documentation    |     Premium Support

PrinterWrapMode options

Hi,

There are two options for PrinterWrapMode (WrapText and AutoSizeText) but neither quite do what our customers would like. What we would like is for the text to stay at the font size the user selected (so cannot auto size) but also not to break up to extra lines - as people want to choose where that happens (so cannot auto wrap either).

Is there a way I can get the desired behaviour?

Regards,
Jonathan

Hi, any thoughts on this one? I was thinking there could have been a 3rd option like:
PrinterWrapMode.Off or .None

Jonathan

Hi Jonathan,
I sent response to the wrong thread yesterday.

Here’s a simple implementation of CustomLabelPrinterLayer which do not wrap nor auto resize text font.
class CustomLabelPrinterLayer : LabelPrinterLayer
{
protected override void DrawCore(GeoCanvas canvas, Collection labelsInAllLayers)
{
if (String.IsNullOrEmpty(base.Text))
{ return; }

	double oneToOneScale = PrinterHelper.GetPointsPerGeographyUnit(canvas.MapUnit);
    float drawingSize = (float)(Font.Size * oneToOneScale / canvas.CurrentScale);
    GeoFont drawingFont = new GeoFont(Font.FontName, drawingSize, Font.Style);
    RectangleShape currentBoundingBox = GetBoundingBox();

    canvas.DrawTextWithWorldCoordinate(base.Text, drawingFont, TextBrush, currentBoundingBox.GetCenterPoint().X, currentBoundingBox.GetCenterPoint().Y, DrawingLevel.LabelLevel);
}

}

Thanks,
Jack

We were also thinking about adding the 3rd option on the PrinterWrapMode, will keep you updated when we have it added.
Thanks,
Jack

Thanks, I will give that a go.

I did try using text with normal spaces replaced with non-breaking spaces and that looked to be working quite well. But suspect I would also need other non-breaking characters, like hyphen and dot, and not sure they exist.

Regards,
Jonathan

Hi Jonathan,
We added PrinterWrapMode.None as third option, and this won’t change font size nor wrap the text. Please give a try and let us know how it works for you.
Thanks,
Jack

That was quick work. I have tried it out and it works very well, thanks.
Regards,
Jonathan