Quantcast

[Bug 61098] New: Certain documents containing forms and XML data get corrupted adding custom properties

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Bug 61098] New: Certain documents containing forms and XML data get corrupted adding custom properties

Bugzilla from bugzilla@apache.org
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: [hidden email]
          Reporter: [hidden email]
  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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Bug 61098] Certain documents containing forms and XML data get corrupted adding custom properties

Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=61098

Ravi Nerella <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All
            Version|unspecified                 |3.16-FINAL

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...