Portion formatting problem

Hi, I have few problems:
1. in one placeholder there is “*” character that is not visible in presentation
2. when writing new portion on place of other, text formatting and size are changed in output file.
3 if you look at attachment presentation, in upper left corner on slide 3 there is a comment, how can I access it?
4. and can you please let me know what’s up with this thread: Portion font format

Here is my code where youu can see how to reproduce this bugs, and test.ppt in attachment.

Thanks, Ivica.

presentation = new Presentation(inputStream);

Slides slides = presentation.getSlides();

Slide slide = slides.get(0);

Shapes shapes = slide.getShapes();

Shape shape = shapes.get(0);

TextFrame textFrame = shape.getTextFrame();

Paragraphs paragraphs = textFrame.getParagraphs();

Paragraph paragraph = paragraphs.get(0);

// first problem
System.out.println(paragraph.getText());

slide = slides.get(1);

shapes = slide.getShapes();

shape = shapes.get(1);

GroupShape groupShape = (GroupShape) shape;

shapes = groupShape.getShapes();

shape = shapes.get(4);

textFrame = shape.getTextFrame();

paragraphs = textFrame.getParagraphs();

paragraph = paragraphs.get(0);

System.out.println(paragraph.getText());

Portions portions = paragraph.getPortions();

portions.clear();

Portion portion = new Portion();

portion.setText(“New Light green portion text.”);

portions.add(portion);

presentation.write(new FileOutputStream(new File(“d:/test_output.ppt”)));

1- These internal * characters are for the internal handling of placeholders and used by MS-PowerPoint.

3- You can read comments like this

SlideComment comment=slide.getComments().get(0);

String strComment=comment.getText();

4- The bug is related to the ppt you provided, you should be able to use other ppts. Meanwhile, we will fix it.

Always access slide via Presentation.getSlideByPosition() method.

Slide slide=presentation.getSlideByPosition(2);// Accessing second normal slide

Thanks, and is there any whay to disctinct this internal character from actual ‘*’ character in a text?

Ivica.

And I must also ask you is there any way to change comments in a slide?

Thanks, Ivica.

You should check if shape.getTextHolder() returns true, if it is so, then you should type cast shape.getPlaceholder() to TextHolder()

if (shape.getTextHolder() == true) {
    TextHolder thld = (TextHolder) shape.getPlaceholder();
    Paragraphs paragraphs = thld.getParagraphs();
}

Then these internal * characters should not appear. However, your provided ppt does not work because of bug, I have reported it.

No, you cannot change/add comments.

Hi, can you tell me what is status on this problem. Can you send me bug fix or something?

Thanks, Ivica

Hello Ivica,

I should tell you there are no any bugs and that is “by design” behavior.
’*’ is meta character in presentations which is calculated dynamically by PowerPoint.
They can be slide number, header, footer and date/time.

Positions of meta characters in a text can be accessed through methods:
TextFrame.getDateTimePosition()
TextFrame.getFooterPosition()
TextFrame.getGenericDatePosition()
TextFrame.getHeaderPosition()
TextFrame.getSlideNumberPosition()

If you need to get text for text frames with meta characters you should check positions of all such characters and replace it with real values.

Hi, if you can tell me how to handle metacharacters if I want to insert them when writing ppt document.

And if I have pargaraph inside TextFrame that has “*” inside, how can I know which type of meta character it is when metacharacters information is on TextFrame level?

Thanks, Ivica.