Hello, I need to rotate a single line of text, of a specified angle, while I'm composing a PDF document, by reading fields from a database.
A code snippet that explains what I want to achieve is something like this:
// Rows contains a collection of objects that represents all the element of the final PDF file
foreach (var row in rows)
{
// Considering only the string objects (the only with a rotation angle)
if(row.Type == "S")
DrawString(row.X, row.Y, row.Text, row.RotationAngle, [...]);
else if(row.Type == "P")
[...Do other stuff...]
}
// For simplicity, all the stuff for create font and format are omitted
private void DrawString(float posX, float posY, string text, int rotationAngle, [...])
{
var font = new PdfTrueTypeFont([...]);
var format = new PdfStringFormat { Alignment = PdfTextAlignment.Left, WordWrap = PdfWordWrapType.Word };
_page.Graphics.DrawString(text, font, PdfBrushes.Black, new PointF(X, Y), format);
// And what about the rotation angle???
// If 90 is passed as RotationAngle I'like to have ONLY this string rotated by 90 degrees.
}
For completeness, if I have these data:
X = 10, Y = 10, Text = "Straight", RotationAngle = 0
X = 20, Y = 10, Text = "Rotated", RotationAngle = 90
X = 30, Y = 10, Text = "Already Straight", TotationAngle = 0
I would like to have a PDF that looks like the picture attached
Attachment:
Sample_e396ddda.zip