In the textbooks that I saw. I learned how to add text when creating a docx file. but then every time I add a line of text. I noticed that there is always a space between the first line of text and the second line of text. same as pressing the enter key twice. I know that the main reason is that every time I add a line of text, I use a paragraph. and the paragraph begins with a space after another paragraph.
This is how I add text
ObjectFactory factory;
factory = Context.getWmlObjectFactory();
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
P spc = factory.createP();
R rspc = factory.createR();
rspc.getContent().add(wordMLPackage.getMainDocumentPart().createParagraphOfText("sample"));
spc.getContent().add(rspc);
java.io.InputStream is = new java.io.FileInputStream(file);
wordMLPackage.getMainDocumentPart().addObject(spc);
therefore, this code runs successfully and produces the correct output. but when I add another paragraph. or text. I want it under the first line of text. Is there a way that I can add a simple line of text without using a paragraph? thanks in advance
EDIT: org.docx4j.wml.Text,
Text newtext = factory.createText();
newtext.setValue("sample new text");
wordMLPackage.getMainDocumentPart().addObject(newtext);
, docx, , .