Bug 53308 - How to produce content with alignment from source document to destination document
Summary: How to produce content with alignment from source document to destination doc...
Status: RESOLVED WONTFIX
Alias: None
Product: POI
Classification: Unclassified
Component: HWPF (show other bugs)
Version: 3.8-FINAL
Hardware: PC Windows XP
: P1 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-28 07:31 UTC by jeyasri021291
Modified: 2016-02-14 20:31 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jeyasri021291 2012-05-28 07:31:48 UTC
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.
Comment 1 Dominik Stadler 2016-02-14 18:45:52 UTC
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.