Aspose Word throw exception at constructor

Hi,

I’m using the latest Aspose.Word version and I’m facing an issue with Aspose when loading this document. Please help me check it. Thank you!

//Code
Document doc = new Document(inFile);

DS-1514 Episode 69 2 Tracks Raw PM-00.docx (91.6 KB)

@dunghnguyen

It seems you are encountering an exception when trying to load a document using Aspose.Words. This issue can arise due to various reasons, such as document corruption, unsupported features, or incorrect loading options.

To troubleshoot this problem, you can try the following steps:

  1. Use LoadOptions: When loading documents, you can specify load options to control the loading process. For example, you can set the Microsoft Word version to ensure compatibility with the document format. Here’s how you can do it:

    LoadOptions loadOptions = new LoadOptions();
    loadOptions.setMswVersion(MsWordVersion.WORD_2019); // or another version as needed
    Document doc = new Document("path/to/your/document.docx", loadOptions);
    
  2. Implement Warning Callback: If the document has issues, you can implement a warning callback to get detailed information about any problems encountered during loading. This can help you identify the specific cause of the exception.

    private static class DocumentLoadingWarningCallback implements IWarningCallback {
        public void warning(WarningInfo info) {
            System.out.println("WARNING: " + info.getWarningType() + " source:" + info.getSource());
            System.out.println("\tDescription: " + info.getDescription());
        }
    }
    
    LoadOptions loadOptions = new LoadOptions();
    loadOptions.setWarningCallback(new DocumentLoadingWarningCallback());
    Document doc = new Document("path/to/your/document.docx", loadOptions);
    
  3. Check for Document Corruption: Ensure that the document you are trying to load is not corrupted. You can try opening it in Microsoft Word to see if it displays correctly.

  4. Use TempFolder: If you are dealing with large documents, consider setting a temporary folder to avoid memory exceptions:

    LoadOptions loadOptions = new LoadOptions();
    loadOptions.setTempFolder("C:\\TempFolder\\");
    Document doc = new Document("path/to/your/document.docx", loadOptions);
    
  5. Load Encrypted Documents: If the document is encrypted, make sure to provide the correct password using the LoadOptions class.

If you continue to face issues, please provide more details about the exception message you are receiving, as this can help in diagnosing the problem further.

Sources:
[1]: Specify Load Options in Java|Aspose.Words for Java - Aspose Documentation

Please test it yourself. The document can be opened just fine by Microsoft Office. Thanks.

@dunghnguyen
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-28064

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.