We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problem in pdf slide when content is added to rich text editor using Aspose Slides and PPTX

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 .

    Hi Laurie,

    Thanks for inquiring Aspose.Slides.

    I have observed the information shared and request you to please share what issue you are incurring while using Aspose.Slides. I also like to share that Aspose.Slides only support importing HTML tags but not rich text. I request you to please share the problem details, working console application, source and generated output. I also request you to please try using Aspose.Slides for Java 15.6.0 on your end as well. Please share the requested details so that I may help you further in this regard.

    Many Thanks,

    Hi Mudassir,

    Thank you very much for your reply. I have used the below code to generate rich text content. For the method, I am getting the input parameter as html text.In the code.
    Please find the details given below.
    ITextFrame frameToFind=searchFrame(presentation, strToFind);
    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); }
    }
    and the searchFrame method is as follows…
    /** 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;
    }

    }
    return null;
    }

    Here is the method from the Aspose API where I adding the html text to the Slide.Pleae find the line of the code given below.

    frameToFind.getParagraphs().addFromHtml(doc.html());
    where frameToFind the is the ITextFrame’s instance,where it contains method called addFromHtml(doc.html()) which takes html text as parameter.

    As per earlier discussions, I have used aspose.slides-15.6.0.jar.

    Please let me know if you require more info on this.

    Hi Laurie,

    I have observed the explanation shared by you and have tried using the sample code shared by you in the very first post that is converting rich text to html using Jsoup jar file. I request you to please save the doc.html on your end by parsing rich text through Jsoup jar file and share the generated html that you are importing in slide. I have tried using the complete code shared by you but have not been able to use that on my end. The point that is concerning to Aspose.Slides is only import of doc.html that you generate. Please share the requested information so that I may help you further in this regard.

    Many Thanks,