You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Chau362 <ch...@gmail.com> on 2018/08/14 14:15:43 UTC
Delete specific XSLFTextParagraph in XSLFShape
I am using XSLF to populate a given PowerPoint document (template) with
values from a Hashmap. Inside the PowerPoint I have one slide with
predefined textShapes. Every textShape has one or more textParagraphs. In
order to fill the template with my own values, I loop over the textShape and
textParagraphs and search for a placeholder in the form "< keyword >"
(without spaces). Whenever I find a placeholer, I want to insert new
paragraphs in form of a bullet point after the position of the placeholder.
However if I try to insert a new paragraph at a specific position they only
appear at the end of the textShape. I use the placeholder to collect the
necessary information about the formatting (fontColor, fontSize, fontFamily
etc.)
The placeholder should not be in the final presentation slide, which is why
I tried to replace/delete it. However whenever I try to replace or remove
the placeholder the presentation still looks the same. So basically my
questions are:
1. How can I remove a specified textParagraph from a textShape?
2. Is it possible to create a textParagraph at a specified position in a
textShape?
I tried
((XSLFTextShape) correctShape).getTextParagraphs().remove(paragraphNumber);
to remove and
((XSLFTextShape) correctShape).getTextParagraphs().add(paragraphNumber,
newParagraph);
to insert, but neither worked.
Thanks in advance!
--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: Delete specific XSLFTextParagraph in XSLFShape
Posted by Chau362 <ch...@gmail.com>.
pj.fanning wrote
> https://github.com/apache/poi/blob/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java
> has an addNewTextParagraph method. There doesn't appear to be a remove
> paragraph method.
>
> You might be able to remove a paragraph by calling the `public
> Iterator
> <XSLFTextParagraph>
> iterator()` and removing the paragraph you want
> to remove from the iterator.
I tried it but apparently it doesn't have any influence on the final
outputted presentation either. Do you have any other ideas to remove an
existing XSLFTextParagraph inside a shape?
I would be fine if I could at least replace the existing content, as it is
used to aggregate the necessary formatting options, for the following text.
--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: Delete specific XSLFTextParagraph in XSLFShape
Posted by "pj.fanning" <fa...@yahoo.com>.
https://github.com/apache/poi/blob/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java
has an addNewTextParagraph method. There doesn't appear to be a remove
paragraph method.
You might be able to remove a paragraph by calling the `public
Iterator<XSLFTextParagraph> iterator()` and removing the paragraph you want
to remove from the iterator.
--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org