Java NullPointerException when saving word Document

Hi,

we are using Aspose words java-sdk :

<dependency>
	<groupId>local.aspose</groupId>
	<artifactId>words</artifactId>
	<version>17.7</version>
</dependency>

We try to save a word document :

try (final NoBomByteArrayOutputStream bos = new NoBomByteArrayOutputStream()) {
    final HtmlSaveOptions saveOptions = new HtmlSaveOptions(SaveFormat.HTML);
    saveOptions.setExportHeadersFootersMode(ExportHeadersFootersMode.FIRST_SECTION_HEADER_LAST_SECTION_FOOTER);
    saveOptions.setExportTocPageNumbers(false);
    saveOptions.setEncoding(StandardCharsets.UTF_8);
    saveOptions.setExportImagesAsBase64(true);
    doc.save(bos, saveOptions);  // Exception is thrown there

    return bos.toUtf8String();
}

We get this exception :

 java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException
 	at com.aspose.words.zzZ04.zzX(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.zzZ04.zzY(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.ShapeRenderer.<init>(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.ShapeBase.getShapeRenderer(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.zzZK4.zzh(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.zzZK3.zzf(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.zzZK8.visitShapeStart(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.Shape.zzZ(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.CompositeNode.acceptCore(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.Shape.accept(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.CompositeNode.acceptChildren(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.CompositeNode.acceptCore(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.Paragraph.accept(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.CompositeNode.acceptChildren(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.CompositeNode.acceptCore(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.HeaderFooter.accept(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.zzZXF.zzZx(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.zzZXF.zzZ(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.zzZXF.zzX(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.zzZXF.zzZSS(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.zzZXF.zzZT3(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.zzZSU.zzZ(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.zzZI3.zzZ(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.Document.zzZ(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.Document.zzZ(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.Document.zzZ(Unknown Source) ~[words-17.7.jar:17.7]
 	at com.aspose.words.Document.save(Unknown Source) ~[words-17.7.jar:17.7]
 	at [...]

The document is attached to the topic.
NPE_docx.zip (28.0 KB)

I have clues on what’s going on : the problem is related with section breaks and headers/footers. When we use ExportHeadersFootersMode.NONE the document is saved without any exception.

Do you know what is the cause of this exception and how we can save the document without skipping headers/footers ?

@Renald_Decreuse,

Thanks for your inquiry. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-16859. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hi,

I see that the linked ticket is closed. Do you have a solution about this problem ?

@Renald_Decreuse,

Thanks for your inquiry. This issue has been resolved. Please use latest version of Aspose.Words for Java 18.6.

The issues you have found earlier (filed as WORDSNET-16859) have been fixed in this Aspose.Words for .NET 18.6 update and this Aspose.Words for Java 18.6 update.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan