Free Support Forum - aspose.com

Read a POT file

I am trying to read a .pot file. I did it the same way that I currently read a ppt file but I am getting an invalid header error. How do I read and grab the text from a pot file? Please help.


This is my code to read a ppt

string strTemp = “”;
Aspose.Slides.Presentation tempPresentation;
try
{
tempPresentation = GetPresentationObject(path);
}
catch (Exception ex)
{
Add_Error(ex.Message, path);
return null;
}

Slide sld = tempPresentation.GetSlideByPosition(1);
foreach (Aspose.Slides.Shape shp in sld.Shapes)
{

if (shp.IsTextHolder)
{
TextHolder th = shp.Placeholder as TextHolder;
strTemp += th.Text + Environment.NewLine;
}
else
{
if (shp.TextFrame != null)
{
Aspose.Slides.TextFrame tf = shp.TextFrame;
strTemp += tf.Text + Environment.NewLine;
}
else
{
if (shp.GetType() == typeof(Aspose.Slides.Table))
{
Aspose.Slides.Table tab = (Aspose.Slides.Table)shp;

for (int r = 0; r < tab.RowsNumber; r++)
{
for (int c = 0; c < tab.ColumnsNumber; c++)
{
if (tab.GetCell(c, r).TextFrame != null)
{
foreach (Aspose.Slides.Paragraph par in tab.GetCell(c, r).TextFrame.Paragraphs)
{
strTemp += par.Text + Environment.NewLine;
}
}
}
}
}
}
}
}

The actual error appears to be when opening the presentation


FileStream presStream = new FileStream(presentationFilePath, FileMode.Open, FileAccess.Read);
Aspose.Slides.Presentation tempPresentation = new Aspose.Slides.Presentation(presStream);

??

Hi Scott,

Thanks for showing keen interest in Aspose.Slides.

I have observed the code snippet and information shared by you. But in order to investigate and resolve the issue, I need the POT file. Please share the presentation file so that we may proceed further toward issue resolution. We appreciate your cooperation in advance.

Thanks and Regards,

I would love to attach but you do not allow the upload of pot files.

Hi Scott,

It would have been really better if you could have shared the presentation file. I have generated a POT template presentation file by my self and tried accessing the text inside it using the code snippet given in documentation section. I have been successfully able to extract the text inside the slides. Please visit this documentation link and use the shared code snippet to serve your purpose.

Thanks and Regards,