Bug 51539

Summary: cannot retain format for word document[.doc] [HWPFDocument]
Product: POI Reporter: sanmoy <sanmoy>
Component: HWPFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: major    
Priority: P2    
Version: 3.8-dev   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: test input file for hwpf
test output file for hwpf

Description sanmoy 2011-07-21 13:22:52 UTC
Created attachment 27306 [details]
test input file for hwpf

I had written a simple code

FileInputStream fileInputStream = new FileInputStream(new File("C:\\in.doc"));
FileOutputStream fileOutputStream = new FileOutputStream(new File("C:\\out.doc"));
HWPFDocument hwpfDocument = new HWPFDocument(fileInputStream);
hwpfDocument.write(fileOutputStream);

After executing the code, output file doesn't retain the original format. All lines have the same font, size, color of the first line. 

Again,
The below code executes perfectly ( for .docx )

FileInputStream fileInputStream = new FileInputStream(new File("C:\\in.docx"));
FileOutputStream fileOutputStream = new FileOutputStream(new File("C:\\out.docx"));
XWPFDocument docx = new XWPFDocument(fileInputStream);
docx.write(fileOutputStream);

xwpf and hwpf behavior should be consistent
Comment 1 sanmoy 2011-07-21 13:24:36 UTC
Created attachment 27307 [details]
test output file for hwpf
Comment 2 Sergey Vladimirov 2011-07-22 07:53:26 UTC
Unable to reproduce using latest code from trunk.

Sanmoy, could you try to use latests JARs from http://encore.torchbox.com/poi-cvs-build/ ?
Comment 3 sanmoy 2011-07-22 09:34:44 UTC
I had tested with poi 3.8-beta3-20110606 which has the problem. This release is available from http://poi.apache.org/download.html.

Now, i have tested with poi-3.8-beta4-20110722, and the code is working fine.

Thank you all for your great effort.