Page 1 of 1

add html content

PostPosted: Wed Feb 27, 2013 3:48 am
by fachhoch
I have a tbl row with a single row containing a place holder I want to replace this place holder with multi line string and this string is html.

To replace the place holder in the tbl I use this

Code: Select all
            Tbl tempTable = getTemplateTable(tables, getKey(placeholder));
            if(tempTable==null)return;
            List<Object> tcs = getAllElementFromObject(tempTable, Tc.class);
            Tc  tc=(Tc)tcs.get(0);
            List<Object> ps = getAllElementFromObject(tc, P.class);
            tc.getContent().remove(ps.get(0));

            for(Object  object  :htmlStrings){
               tc.getContent().add(object);
            }



My question is how to convert html text to a Paragraph.Please advice.

Re: add html content

PostPosted: Wed Feb 27, 2013 6:22 am
by jason
Please see the sample ConvertInXHTMLFragment, which uses XHTMLImporter

Re: add html content

PostPosted: Wed Feb 27, 2013 11:04 pm
by fachhoch
I want to convert html strings to paragraph , the example shows

Code: Select all
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
             XHTMLImporter.convert( input, null,wordMLPackage) ;


in my case I want to create paragraphs with the html text and add these paragraphs to tablerow.

Code: Select all
Tbl tempTable = getTemplateTable(tables, getKey(placeholder));  // get my table

            List<Object> tcs = getAllElementFromObject(tempTable, Tc.class); // get all tableContent size is just one
            Tc  tc=(Tc)tcs.get(0);  // get the first table content
            List<Object> ps = getAllElementFromObject(tc, P.class);  // find all paragraphs   I know only one exsists at this point
            tc.getContent().remove(ps.get(0)); //  remove the  first  Paragraph
            for(Object  object  :childObjects){   // here childobjects are paragraphs  made out of html string  I need help here ?
               tc.getContent().add(object);
            }

Please advice I have html string and want to convert them to List of Paragraphs.