We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Importing a section more than once causes an error when opening the doc - in some cases

Hi,

In the code snippet below, I am importing a section from a source document to my result document 2 times.

Under some conditions, after the document is generated, I am getting a Word error as I try to open the document:
“The file document.docx cannot be opened because there are problems with the contents.
Details: Unspecified Error
Location: Part: /word/document.xml, line 3, column 0” - see the attachment error1.jpg.

After I click OK, another popup displays (see attachment error2), where after clicking “Yes” the document opens, and looks OK.

I am attaching source files I used to generate the issue, sourceFile1.docx and sourceFile2.docx

It seems that the error happens only if

  • I use Aspose.Word 11.9.0 (it does not happen with Aspose.Word 10.6.0 we used before)
  • I am saving in word 2010 format (it does not happen it doc saves in compatibility mode)
  • document section contains a shape (line or other shape) - sourceFile1.docx
  • if document contains pictures, it works OK, but if these pictures are grouped, I get the same error - sourceFile2.docx

Code snippet I use:

try
{
    Document source = new Document("c:/sourceFile1.docx");
    Document doc = new Document();

    BookmarkCollection bookmarks = source.getRange().getBookmarks();
    Bookmark bookmark = bookmarks.get("general");
    Node sourceDocSection = bookmark.getBookmarkStart().getAncestor(NodeType.SECTION);
    Node docSection = doc.importNode(sourceDocSection, true);
    doc.appendChild(docSection);

    // second time
    Node sourceDocSection2 = bookmark.getBookmarkStart().getAncestor(NodeType.SECTION);
    Node docSection2 = doc.importNode(sourceDocSection2, true);
    doc.appendChild(docSection2);

    OoxmlSaveOptions saveOptions = new OoxmlSaveOptions(SaveFormat.DOCX);
    saveOptions.setCompliance(OoxmlCompliance.ISO_29500_2008_TRANSITIONAL);
    doc.save("c:/document.docx", saveOptions);

    System.out.println("All done!");
}
catch (Exception ex)
{
    System.out.println("Error: " + ex.getMessage());
}

Please let me know if you have any questions about the issue. Also, please let me know if there is any workaround for this issue or when can we expect this to be fixed.
Thanks,

Natasa

Hi Natasa,

Thanks for your inquiry. While using the latest version of Aspose.Words i.e. 11.9.0, I managed to reproduce this issue on my side. I have logged this issue in our bug tracking system. The issue ID is WORDSNET-7398. Your request has been linked to this issue and you will be notified as soon as it is resolved. Sorry for the inconvenience.

Best regards,

Hi Natasa,

Thanks for your patience. We have a good news for you that is WORDSNET-7398 has now been resolved and its fix will be included in the next version of Aspose.Words (v11.11.0) which is planned to be released by the end of this month. We will inform you via this forum thread as soon as the new release is published.

Best regards,

The issues you have found earlier (filed as WORDSNET-7398) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Hi,

Thanks for the timely manner in which you attended to this issue.

We have tested the Aspose.Words 11.11.0 release with our files, but this issue does
not seem to be resolved completely; or maybe - by fixing it - another issue was
introduced.

First of all - when testing scenarios reported in the
original message, I am getting inconsistent results, meaning it works
sometimes and it does not work another time. I was not able to figure
out any pattern or reason why the results could be inconsistent. Basically, I run the code snippet from the original message over and over and checking the results. With no other things changed, sometimes the generated file is OK, and opens without any problems, other times, the generated file is NOT OK, and I am getting kind of similar error as in the original message:

“The file document.docx cannot be opened because there are problems with the contents.
Details: Unspecified Error
Location: Part: /word/document.xml, line 1, column 0”

This time, I am not able to open the document after clicking OK.

However, another issue was discovered in this new release (11.11.0),
with the same scenario - by importing a section more than once. This
time, if the original file contains an image and a table and the image
has text wrap set as in the attached sourceFile4.docx (text wrap = behind the text), then we get the same error as above when opening the result generated document. This error with this file and scenario is generated consistently.
If the text wrap setting was default one: In Line With Text, all would work OK. Also, this scenario works OK in release 11.9.0 or earlier ones.

Please let me know if you have any questions. Also, please let me know when can we expect this to be fixed.
Thanks,

Natasa

Hi Natasa,

Thanks for the additional information.

While using the latest version of Aspose.Words i.e. 11.11.0, I managed to reproduce this issue on my side as well. I have logged this issue in our bug tracking system. The issue ID is WORDSNET-7680. Your request has been linked to this issue and you will be notified as soon as it is resolved.

Sorry for the inconvenience.

Best regards,

The issues you have found earlier (filed as WORDSNET-7680) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.