Bug 53378 - When a new para is added to the attached document and saved, document is corrupted.
Summary: When a new para is added to the attached document and saved, document is corr...
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: HWPF (show other bugs)
Version: 3.8-FINAL
Hardware: PC Windows XP
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-07 09:39 UTC by Kaushal
Modified: 2012-06-07 09:46 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kaushal 2012-06-07 09:39:14 UTC
I opened the attached document "tutorial.doc" and added a new para and saved the document (attached as tutorialop.doc). When I open tutorialop.doc in MS Word, MS word shows an error on document open saying some tables in the document have been corrupted and asks me to use the repair document option.
Comment 1 Kaushal 2012-06-07 09:44:39 UTC
The document can be got from 

https://docs.google.com/open?id=0B1wVJ9Jz7lCeYTdESk5wM2RNOFU


The output that got generated can be got from 
https://docs.google.com/open?id=0B1wVJ9Jz7lCeUVk0NGt3aWZHMmM
Comment 2 Kaushal 2012-06-07 09:46:30 UTC
The code i used to do the changes is as below: I have added this to the main in QuickTest.java that comes with the POI HWPF source code.
 
HWPFDocument doc = new HWPFDocument (new FileInputStream ("C:/tutorial.doc"));
Range r = doc.getRange();

     System.out.println("Example you supplied:");
      System.out.println("---------------------");
      Section s = r.getSection(0);
      Paragraph p = s.getParagraph(1);
      
      p.insertAfter("KC KC KC");
      
      OutputStream out = new FileOutputStream("C:/tutorialOp.doc");
      
      doc.write(out);
      out.close();