Hi ,
This is regarding in generation of content on PDF slide using PPTX. We are displaying the content on PDF slide whatever content is added to rich text editor. We are unable to see the content in the next slide
whenever more content is being added to the Rich text editor.All the content is being displayed in a single slide rather than moving to next slide. Please find the code given below. Please find the screen shots as attachments as well.
Here is the code:
private static void replaceRichTextField(Presentation presentation, String strToFind, Field field){
String richText=String richtext = “
- ”
- Set up workshops to define the MVP scope”
+ “- Business level workshop ”
- Technical workshop(s)
+ “
+ “ ” - IBM to summarize MVP scope for review by business and IT ”
- Review of use cases and MVP scope ”
- Incorporate feedback and kick-off project ”
- IBM1 ”
- IBM2 ”
- IBM3 ”
- IBM4 ”
- IBM5 ”
- IBM6
"
+ “
+ “
+ “
+ “
+ “
+ “
+ “
+ “
+ “
+ “
+ “
if(field !=null){
System.err.println(“The field object is not null and and the field value " +field.getValue());
richText=field.getValue();
}
else
{
System.err.println(“The field value object is null “);
}
System.err.println(“The value of the field value in rich text field value is::”+richText);
richText = richText.replaceAll(”
”, “
richText = richText.replaceAll(””, “
Document doc = Jsoup.parse(richText);
/doc.select(“p”);
Elements elements1 = doc.getElementsByTag(“p”);
elements1.tagName(“li”);/
Elements elements2 = doc.getElementsByTag(“ul”);
for (Element element : elements2) {
processBulletElements(doc, element);
for (Element elemsibling : element.siblingElements()) {
processBulletElements(doc, elemsibling);
}
}
Elements elements3 = doc.getElementsByTag(“ol”);
for (Element element : elements3) {
processBulletElements(doc, element);
for (Element elemsibling : element.siblingElements()) {
processBulletElements(doc, elemsibling);
}
}
System.out.println(doc.html());
// System.err.println(“The richText actual value is::::”+richText);
// String richTextWithOl= richText.substring(richText.indexOf("
- "+4,richText.lastIndexOf("
// System.err.println(“The rich text value after removing the
- elements are::::richTextWihoutUl :::”+richTextWihoutUl);
// System.err.println(“The rich text value after removing the
- elements are::::richTextWihoutOl :::”+richTextWithOl);
// System.err.println(“The rich text value after removing the
- elements are :::”+richText);
ITextFrame frameToFind = searchFrame(presentation, strToFind); // find parameter to replace
if (frameToFind != null) {
frameToFind.getParagraphs().clear();
System.err.println(“The richText format value after clearing the frameToFind” +doc.html());
frameToFind.getParagraphs().addFromHtml(doc.html());
} else { LOG.warning("Rich text parameter not found: " + strToFind); }
}
private static void processBulletElements(Document doc, Element element) {
String ulhtml = element.html();
if(element.previousSibling()!=null){
Node prevElem = element.previousSibling();
System.err.println(element.previousSibling());
element.remove();
prevElem.after(ulhtml);
}else if(element.nextSibling()!=null){
Node nextElem = element.nextSibling();
System.err.println(element.nextSibling());
element.remove();
nextElem.before(ulhtml);
}else{
doc.html(ulhtml);
}
}
/** Search all text frames that contain the parameter tag strToFind */
private static ITextFrame searchFrame(Presentation presentation, String strToFind) {
ITextFrame[] textFrames = SlideUtil.getAllTextFrames(presentation, true);
for (ITextFrame frame : textFrames) {
if (frame.getText().contains(strToFind) ) {
return frame;
}
We have used JSOUP for the parsing of html tags. The above, I have declared html text as hard coded value and assigned to a variable called richText.This richText variable value I am displaying on the PPTx slide and it is displaying as per the richText value .
Please find the attached screen shot .