Hello everyone,
I have two problem with Poi api 3.7 and 3.8 (I tried both):
1) When I save a word document with poi, the fonts are not the same as the
original document.
I use this code:
File iFile = new File("D:/empty.doc");
File oFile = new File("D:/doc.doc");
InputStream fis = new FileInputStream(iFile);
POIFSFileSystem fs = null;
HWPFDocument doc = null;
try {
fs = new POIFSFileSystem(fis);
} finally {
fis.close();
}
doc = new HWPFDocument(fs);
OutputStream out = new FileOutputStream(oFile);
try {
doc.write(out);
out.flush();
} finally {
out.close();
}
The empty.doc file is:
http://apache-poi.1045710.n5.nabble.com/file/n4622539/empty.jpg
The doc.doc file is:
http://apache-poi.1045710.n5.nabble.com/file/n4622539/doc.jpg
The fonts are not same.
2) The method "replaceText(String,String)" has corrupted the Word file.
I use this code:
File iFile = new File("D:/empty.doc");
File oFile = new File("D:/doc.doc");
InputStream fis = new FileInputStream(iFile);
POIFSFileSystem fs = null;
HWPFDocument doc = null;
try {
fs = new POIFSFileSystem(fis);
} finally {
fis.close();
}
doc = new HWPFDocument(fs);
Range r = doc.getRange();
*
System.out.println("original text : " + r.text());
r.replaceText("<NOM>", "Moi");
System.out.println("modified text : " + r.text());
*
OutputStream out = new FileOutputStream(oFile);
try {
doc.write(out);
out.flush();
} finally {
out.close();
}
The empty.doc file is the same and the doc.doc file is corrupted.
The "println()" method give me that:
run:
original text : Mr <NOM>Mr <NOM>
modified text : Mr MoiMr Moi
BUILD SUCCESSFUL (total time: 1 second)
And when I try to open the doc.doc file, I have this error:
http://apache-poi.1045710.n5.nabble.com/file/n4622539/error.jpg
Thanks for your help.
--
View this message in context:
http://apache-poi.1045710.n5.nabble.com/problem-with-the-methode-replaceText-and-with-save-HWPFDocument-tp4622539p4622539.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]