Bug 51539 - cannot retain format for word document[.doc] [HWPFDocument]
Summary: cannot retain format for word document[.doc] [HWPFDocument]
Alias: None
Product: POI
Classification: Unclassified
Component: HWPF (show other bugs)
Version: 3.8-dev
Hardware: PC All
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2011-07-21 13:22 UTC by sanmoy
Modified: 2011-07-22 09:34 UTC (History)
0 users

test input file for hwpf (26.00 KB, application/msword)
2011-07-21 13:22 UTC, sanmoy
test output file for hwpf (20.00 KB, application/msword)
2011-07-21 13:24 UTC, sanmoy

Note You need to log in before you can comment on or make changes to this bug.
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);

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

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);

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.