I used this code to create my simple heading paragraph:
Code:
Paragraph heading = currentSection.AddParagraph();
heading.Tag = "Heading";
heading.AddText("Data Sheet"));
heading.Format.Font.Size = 20;
heading.Format.Font.Color = MigraDoc.DocumentObjectModel.Colors.Black;
heading.Format.Font.Name = fontName;
heading.Format.Alignment = ParagraphAlignment.Left;
heading.Format.FirstLineIndent = "0mm";
// render the heading paragraph
docRenderer.RenderObject(currentGfx, XUnit.FromCentimeter(1.3), XUnit.FromCentimeter(1.1), "8cm", heading);
I used the code bellow to paint the dimensions of my simple paragraph:
Code:
Console.WriteLine("Heading Info:");
XPen pena = new XPen(XColor.FromKnownColor(XKnownColor.YellowGreen), 1);
currentGfx.DrawLine(pena, new System.Windows.Point(renderInfos[g].LayoutInfo.ContentArea.X, renderInfos[g].LayoutInfo.ContentArea.Y), new System.Windows.Point(renderInfos[g].LayoutInfo.ContentArea.X + renderInfos[g].LayoutInfo.ContentArea.Width, renderInfos[g].LayoutInfo.ContentArea.Y));
Console.WriteLine("x:" + (double) renderInfos[g].LayoutInfo.ContentArea.X);
Console.WriteLine("y:" + (double)renderInfos[g].LayoutInfo.ContentArea.Y);
Console.WriteLine("width:" + (double)renderInfos[g].LayoutInfo.ContentArea.Width);
Console.WriteLine("height:" + (double)renderInfos[g].LayoutInfo.ContentArea.Height);
currentGfx.DrawLine(pena, new System.Windows.Point(renderInfos[g].LayoutInfo.ContentArea.X, renderInfos[g].LayoutInfo.ContentArea.Y), new System.Windows.Point(renderInfos[g].LayoutInfo.ContentArea.X, renderInfos[g].LayoutInfo.ContentArea.Y + renderInfos[g].LayoutInfo.ContentArea.Height));
Here is the text output for the leading simple paragraph:
x:70,8661417322835
y:70,8661417322835
width:453,543307086614
height:24,72
Since approx. 28 pt = 1 cm i would expect to have X and Y value at slightly more than 30 pt but less than 40 pt (but i got 70 pt).
Maybe there is a misinterpretation of points to centimeters here.
The lines drawn on my pdf do not match my paragraph. Why?
Plus, i wonder why X and Y are the same when i gave it X = 1.3 cm and Y = 1.1 cm?