Pregunta

Is there any way to change any property of a paragraph after I added to the MainDocumentPart ?

WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
MainDocumentPart mdp = wordMLPackage.getMainDocumentPart();
mdp.addStyledParagraphOfText("NormalIndent", "The following PHP error occurs: ");

In the last row i want preserve the whitespace using setSpace("preserve"), but how?

Thanks, roncsak

¿Fue útil?

Solución

Disclosure: I work on docx4j

Get the paragraph, you just added; get the first run from the paragraph; get the first Text object from the run, the use setSpace("preserve")

The ContentAccessor interface can be used to get the paragraph, the run, and the Text object ie invoke getContent(), which returns a List

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top