PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

Writing text inside oddly shaped polygons
http://forum.pdfsharp.com/viewtopic.php?f=2&t=2854
Page 1 of 1

Author:  ariscol [ Wed Jul 02, 2014 5:34 am ]
Post subject:  Writing text inside oddly shaped polygons

I have some code that creates many oddly shaped polygons (e.g.: parallelograms, trapezoids, hexagons, and other unclassified mostly random shapes) based on inputs to the program, or in other words, the shapes are not static. Each shape is drawn by code that looks like this:

Code:
gfx.DrawPolygon(pen, points);//(points is an XPoint[])

//Now we need to write "Hello World" into the polygon we just drew


As the last comment suggests, my question is if there is any easy/simple way (I'm really new to pdfSharp) to write text to this polygon. By looking at the examples on the website, it looks like the way to draw text is to use XTextFormatter.DrawString(...), but that takes an XRect parameter... Is there a built-in way to get the biggest possible XRect from a polygon? Or maybe some other way to write text to any polygon rather than being tied to an XRect?

Any help would be greatly appreciated. And, I apologize in advance if I've asked a bad question on account of my ignorance.

Author:  Thomas Hoevel [ Wed Jul 02, 2014 7:47 am ]
Post subject:  Re: Writing text inside oddly shaped polygons

Hi!

The question is not bad, but you have to do the calculations in your code. Neither PDFsharp nor MigraDoc implement this.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/