ThinkGeo.com    |     Documentation    |     Premium Support

PdfGeoCanvas does not respect \n when labeling

I have label routine that uses canvas.DrawTextWithWorldCoordinate to draw the text.  When the canvas is a GDIPlusCanvass, the labels are stacked properly, when the canvas is a PDFGeoCanvas, the \n is replaced with two spaces.


Is this a bug or is there a workaround?


 


Ed



Ed,


Thanks for your post and question.
 
I think this could be considered as a potential bug in PdfSharp, which use the XGraphics instead of .net Graphics to draw the string.
 
Following is my suggested go around way with code snippet:

gdiPlusGeoCanvas.DrawTextWithWorldCoordinate("Hello Yang \n This is new line", new GeoFont("Arial", 10), new GeoSolidBrush(GeoColor.SimpleColors.Red), width/2, height/2, DrawingLevel.LevelOne);

 
while in PdfGeoCanvas Drawing:

string str = "Hello Yang \n This is new line";
string[] strs = str.Split('\n');
int strCount = 0;
foreach (string eachStr in strs)
{
    pdfGeoCanvas.DrawTextWithWorldCoordinate(eachStr, new GeoFont("Arial", 10), new GeoSolidBrush(GeoColor.SimpleColors.Red), width / 2, height / 2 + strCount * 10, DrawingLevel.LevelOne);
   strCount++;
}

 
Any more questions just feel free to let us know.
 
Thanks.
 
Yale