Pptx text formatting

Hi there

I’m implementing read/write support for a software product using Aspose.Slides. We’re really only interested in modifying the text as our software is a document localisation tool. I’m trying to get text formatting properties from the PortionEx objects inside every paragraph but they dont seem to contain any values or have NaN as a value.

In the Slides helpfile it says “float.NaN means (property x) is
undefined and should be inherited from the Master.” I presumed this meant the master slide, but I couldnt see any formatting properties contained in there that would be relevant. If you could help point me in the right direction, it would be great, thanks!

Eric

Hi Eric,

The font style properties work correctly except when inherited from the master / layout slide. An issue with issue id 11866 has been created for fix of this issue and you will be informed as soon as it is resolved.

Hi Muhammad,

Thanks for your reply. I had a look at the LayoutSlideEx, TextCharacterPropertiesEx but did not see any properties concerning inheritable font styles as such. I was wondering if you could direct me to the classes which contain these properties, such as the Pptx equivalent of the Master slide class in the PPT API.

Thanks

Eric

Hi Eric,

1) Let me explain my point. Attached is a presentation with two slides. In slide at position 1, font style is different from the master slide and is readable through Aspose. In slide at position 2, font style is same as master slide and can't be read through Aspose. I have used the following code to read font height:

PresentationEx pres = new PresentationEx("d:\\ppt\\shane\\pptxfont.pptx");

SlideEx sld1 = pres.Slides[1];

SlideEx sld2 = pres.Slides[0];

//Reads Font Height as font is different from master slide

foreach (ShapeEx shp in sld1.Shapes)

{

if (shp is AutoShapeEx)

{

AutoShapeEx ashp = (AutoShapeEx)shp;

TextFrameEx tf2 = ashp.TextFrame;

if (tf2 != null)

{

PortionEx port = tf2.Paragraphs[0].Portions[0];

Response.Write("Slide1 Font Height = " + port.RawFontHeight.ToString() + "
");

}

}

}

//Fails to read Font Height and results NaN as font is same as master slide

foreach (ShapeEx shp in sld2.Shapes)

{

if (shp is AutoShapeEx)

{

AutoShapeEx ashp = (AutoShapeEx)shp;

TextFrameEx tf2 = ashp.TextFrame;

if (tf2 != null)

{

PortionEx port = tf2.Paragraphs[0].Portions[0];

Response.Write("Slide2 Font Height = " + port.RawFontHeight.ToString()+"
");

}

}

}

2) If you try to access the font height in master / layout slide through Aspose, will result in NaN again. This is the issue that is under investigation. For accessing Master Slide in PPTX, we have PresentationEx.Masters property returning an array of MasterSlideEx objects. For more information on MasterSlideEx, visit:

http://www.aspose.com/documentation/.net-components/aspose.slides-for-.net/aspose.slides.pptx.masterslideex.html

Hi Muhammad

Thanks for your reply. If I understand it correctly then, if a PPTX file has its text style information defined in the Master slide and nowhere else, then the formatting information for that text is completely inaccessible?

If this is the case, then would exporting the PPTX file back to a PPT file in PowerPoint be a sufficient workaround to this issue?

Thanks

Hi Eric,

You are right. If you convert your pptx to ppt, there will be no more exception while reading text format.

Hi,
Is issue 11866 solved or not??

I am using Aspose.Slided 2.3.0 still getting NaN for font heights when using getRawFontHeight().
(Getting NullPointerException when getFontHeight() is used… )

How to get around this issue??

Cheers,
Nachiket

Dear Nachiket,

The issue of getting NaN for font heights when using getRawFontHeight() has been resolved. Actually, If your font style is same as your master slide, RawFontHeight returns NAN and RawLatinFont raises NullPointerException. However, if you change the font style in slide, it works fine. For your reference, I have also attached the sample PPTX, that you can test with the code snippet provided.

Thanks and Regards,

Hi Mudassir, Thanks for your quick response.

You wrote:
Actually, If your font style is same as your master slide, RawFontHeight returns NAN

Okay, I can get fontHeight from MasterSlide using
masterSlide.getTitleStyle().getLevels().get(0).getDefaultCharacterProperties().getRawFontHeight() &
masterSlide.getBodyStyle().getLevels().get(0).getDefaultCharacterProperties().getRawFontHeight();

But, how to identify whether TextShape/Paragraph is title paragraph or not? Unable to find anything in tutorial/documentation… Found this thread - How to read the title placeholder from a Powerpoint 97-2003 Presentation (.ppt)?
Tried but seems not working …

Any hint/guidance is welcome. :slight_smile:

Dear Nachiket,

I regret to inform you that there is no direct method to identify whether the paragraph is title paragraph or not. As a a work around you may use the AlternativeText property by setting user defined text for Title and Subtitle shapes and by comparing the text you can decide whether the text inside the paragraphs of the shape is title or subtitle.

Thanks and Regards,