I am trying to copy the content from a particular paragraph in a .docx to
another empty .docx .the problem i have is that the style,bullets,numbering
etc from the source.docx is not retainedin the destination .docx..here is my
code
can anyone please tell me what are the changes to be added to the above
code? Thanks in Advance!!
public class WordFinal {
public static void main(String[] args) throws IOException,
XmlException {
XWPFDocument doc = new XWPFDocument(new FileInputStream("source.docx"));
XWPFDocument destDoc =new XWPFDocument();
OutputStream out = new FileOutputStream("Destination.docx");
XWPFParagraph pr =doc.getParagraphs()[1];
String copy=pr.getText();
XWPFParagraph paragraphOne = destDoc.createParagraph();
XWPFRun paragraphOneRunOne = paragraphOne.createRun();
paragraphOneRunOne.setText(copy);
destDoc.write(out);
}
}
--
View this message in context:
http://apache-poi.1045710.n5.nabble.com/How-to-copy-a-paragraph-of-docx-to-another-docx-withJava-and-retain-the-style-tp5650832p5650832.html
Sent from the POI - Dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]