Page 1 of 1

convertAltChunks

PostPosted: Fri Jun 28, 2013 7:44 pm
by sreejiths_123
Hi ,

I am adding dynamic XHTML contents to existing docx template by the following the way as described below,

Code: Select all
  WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
                MainDocumentPart mdp = wordMLPackage.getMainDocumentPart();
               
                mdp.addParagraphOfText("Paragraph 1");

                // Add the XHTML altChunk
                String xhtml = "my  xhtml goes here";
                mdp.addAltChunk(AltChunkType.Xhtml, xhtml.getBytes());
               
                mdp.addParagraphOfText("Paragraph 3");
               
                // Round trip
                mdp = mdp.convertAltChunks();
               
               


What i dont understand is the purpose of calling mdp.convertAltChunks();

While i use this , i am getting error in log , as

27.June.2013 13:01:38 39246 ERROR [SwingWorker-pool-406181968-thread-1] org.docx4j.model.properties.PropertyFactory (createPropertyFromCssName:545) - What to do for text-decoration:none
27.June.2013 13:01:38 39246 ERROR [SwingWorker-pool-406181968-thread-1] org.docx4j.model.properties.Property (<init>:70) - No support for unit 1


but the conversion works even without the call to convertAltChunks & then the above error disappears. So i am little bit confused , do i really needs to call this ?

Thanks ,
Sreejith

Re: convertAltChunks

PostPosted: Sat Jul 06, 2013 7:17 pm
by jason
You need to invoke convertAltChunks() if you want docx4j to convert an altChunk of type XHTML to native WordML content.

If you don't invoke convertAltChunks(), then it is up to some other processor (eg Word) to do the conversion. Word will do it automatically, so that's why the conversion may still appear to "work".

Re: convertAltChunks

PostPosted: Tue Jul 30, 2013 7:55 pm
by sreejiths_123
Thanks Jaison for that info .