Hello,
I received wrong portion coordinates. What I try doing is to get correct coordinates for each text symbol on the slide. But I realized that I had received wrong coordinates. Here is my code, results are attached. I had drawn received coordinates in paint and here is what I got. Black rect (test_1.png file) is shape’s border, dark red - received portions rect, blue rect is what I expected to have. Moreover, below list “Option 2” I received negative X coordinates for all items so I can’t even draw a border. Am I missing something or error is not on my side?
using (Presentation presentation = new Presentation("C:\\test.pptx"))
{
for (int i = 0; i < presentation.Slides.Count; i++)
{
foreach (IAutoShape shape in presentation.Slides[i].Shapes)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Shape. \tX: " + shape.X + "; Y: " + shape.Y + "; Width: " + shape.Width + "; Height: " + shape.Height);
ITextFrame textFrame = shape.TextFrame;
foreach (IParagraph paragraph in textFrame.Paragraphs)
{
foreach (IPortion portion in paragraph.Portions)
{
Console.ForegroundColor = ConsoleColor.Gray;
Console.WriteLine(portion.Text + "; X: " + portion.GetRect().X + "; Y:" + portion.GetRect().Y + "; Width: " + portion.GetRect().Width + "; Height: " + portion.GetRect().Height);
}
}
Console.WriteLine();
}
}
}
Thanks,
Alex
example.zip (1.4 MB)