Free Support Forum - aspose.com

Maybe wrong documentation?

I found the following peice of example code on your website:

http://www.aspose.com/wiki/default.aspx/Aspose.PowerPoint/ParagraphsAndFonts.html

[C#]

Slide slide1 = GetSlideByPosition(pres, 1);
Shape shape = slide1.Shapes[0];
Paragraph para = shape.TextFrame.Paragraphs[0];

When i add this code to my project, i do not get to read any of the portions that come from the paragraphs on the TextFrame. My exact code is below:

foreach(Shape shape in slide1.Shapes)
{
string pastpptfield = “”;
string workingwith = “”;
if(shape is TextFrame)
{
// the code never enters this structure
foreach(Paragraph para in shape.TextFrame.Paragraphs)
{

and the code goes on. Can anyone please tell me why the shape is never TextFrame? I did some checking and it turns out all the texboxes i want to edit show up as shape “Rectangle” instead of TextFrame.

Any help would be appreciated.

Thanks,
Sean Mahoney

For a bit more information…

I have this program go through each slide and 1 - iterate through all the shapes, and 2 - iterate through all the placeholders. Looking at your object model for Aspose.PowerPoint, i see that TextFrame has the same properties as TextHolders. So, the code should be the same to read from both of those objects, correct?

Anyway below is the code i use to go through each portion of a placeholder:
The TextFrames one is identical, except for the for loop in the beginning, which is replaced by what i wrote above with the whole “foreach (shape shape in slide1.shapes).

Thanks guys,
Sean Mahoney

for(int j = 0; j < slide1.Placeholders.Count; j++)

{
string pastpptfield = “”;
string workingwith = “”;
Placeholder holder = slide1.Placeholders[j];
if (holder is TextHolder)
{
foreach(Paragraph para in ((TextHolder)holder).Paragraphs)
{
foreach(Portion port in para.Portions)
{
workingwith = pastpptfield + port.Text;
textBox1.Text = textBox1.Text + " workingwith: " + workingwith + “\n”;
Regex reg = new Regex(”<<((.|\n)*?)>>", RegexOptions.IgnoreCase);
foreach(Match objMatch in reg.Matches(workingwith))
{
string pptField = objMatch.ToString().Substring(2,objMatch.ToString().Length-4);
textBox1.Text = textBox1.Text + " pptfield (TextHolder): " + pptField + “\n”;
if(dv.Table.Columns.Contains(pptField))
{
string newPort = port.Text.Replace(objMatch.ToString(),dr[pptField].ToString());
pastpptfield = “”;
port.Text = newPort;
}
else
{
// if we dont find one, add this portion to the text and move on
pastpptfield = pastpptfield + port.Text;
port.Text = “”;
}
}
}
}
}
}