Hi, I'm facing problem with alignment when I read a source document(source.doc) to write a new document(new doc) with same content in multiple page.It is not come with source document(source.doc) alignment. I'm struggling on that for a past week. Can you please send me, how to resolve that? My code is here, WordExtractor extractor = null; File file = new File("C:\\source.doc"); POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(file)); HWPFDocument doc = new HWPFDocument(fs); HWPFDocument finalDoc = new HWPFDocument(fs); Range range = finalDoc.getRange(); extractor = new WordExtractor(doc); String paragraphs[]=extractor.getParagraphText(); int paragraphsLength=paragraphs.length; paragraphsLength=paragraphsLength-1; Paragraph par1 = range.insertAfter(new ParagraphProperties(),0); for (int i=0; i<=4; i++) { for (int j=0; j < paragraphs.length; j++){ Paragraph p=range.getParagraph(j); String para1=paragraphs[paragraphsLength-j]; if(p.getJustification()==0){ par1.setJustification((byte) 0); }else if(p.getJustification()==2){ par1.setJustification((byte) 2); } par1.insertBefore( para1); } } OutputStream out = new FileOutputStream(new File("C:\\new.doc")); finalDoc.write(out); out.flush(); out.close(); Thanks in Advance.
No update for a long time, therefore I am closing this, please reopen with more information like the source document if this is still a problem for you.