https://bz.apache.org/bugzilla/show_bug.cgi?id=61098
Bug ID: 61098
Summary: Certain documents containing forms and XML data get
corrupted adding custom properties
Product: POI
Version: unspecified
Hardware: PC
Status: NEW
Severity: major
Priority: P2
Component: HWPF
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
Created attachment 34995
--> https://bz.apache.org/bugzilla/attachment.cgi?id=34995&action=edit
The attached document gets corrupted after adding custom attributes
Following code is used to add custom attributes to the attached document
private String updateWordDocContent(String tempOutputFile) {
File inputFile = null;
File outputFile = null;
FileInputStream fileIStream = null;
FileOutputStream fileOStream = null;
HWPFDocument wordDoc = null;
try {
System.out.println("updateWordDocContent() ");
// APACHE POI
inputFile = new File(tempOutputFile);
fileIStream = new FileInputStream(inputFile);
wordDoc = new HWPFDocument(fileIStream);
DocumentSummaryInformation docSummary =
wordDoc.getDocumentSummaryInformation();
System.out.println(docSummary.toString());
CustomProperties cp = docSummary.getCustomProperties();
if (cp == null)
cp = new CustomProperties();
cp.put("Product", "");
cp.put("Author", "Sean Smith");
cp.put("OS", "Linux");
cp.put("Comments", "Code for POI Word With Doc");
cp.put("extension", "Super OTX");
docSummary.setCustomProperties(cp);
fileIStream.close();
outputFile = new
File(tempOutputFile+"-customPro"+System.nanoTime()+".doc");
fileOStream = new FileOutputStream(outputFile);
wordDoc.write(fileOStream);
fileOStream.flush();
fileOStream.close();
return tempOutputFile;
} catch (Exception e) {
DfLogger.error(this, "Error: " + e.getMessage(), null,
e);
e.printStackTrace();
} finally {
if (fileIStream != null) {
try {
fileIStream.close();
fileIStream = null;
} catch (Exception ex) {
}
}
if (fileOStream != null) {
try {
fileOStream.flush();
fileOStream.close();
fileOStream = null;
} catch (Exception ex) {
// I G N O R E //
}
}
}
return null;
}
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]