Free Support Forum - aspose.com

java.lang.NullPointerException is thrown while converting DOCX to HTML using Java 7

Hi!

Using java com.aspose:aspose-words:20.7:jdk17, we try to save a document with this code:

		Document doc = new Document(new FileInputStream(new File("<path to the file>")));
		try (final WordConverterAsposeLocal.NoBomByteArrayOutputStream bos = new WordConverterAsposeLocal.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
			bos.toUtf8String();
		}

and this document: NPE triggerring document.zip (65.2 KB) we got a nice NullPointerException:

java.lang.NullPointerException
	at com.aspose.words.zzZTW.zzZlf(Unknown Source)
	at com.aspose.words.zzZV2.zze(Unknown Source)
	at com.aspose.words.zzZG2.visitParagraphStart(Unknown Source)
	at com.aspose.words.Paragraph.zzZ(Unknown Source)
	at com.aspose.words.CompositeNode.acceptCore(Unknown Source)
	at com.aspose.words.Paragraph.accept(Unknown Source)
	at com.aspose.words.CompositeNode.acceptChildren(Unknown Source)
	at com.aspose.words.CompositeNode.acceptCore(Unknown Source)
	at com.aspose.words.Comment.accept(Unknown Source)
	at com.aspose.words.zzZV2.zzYH(Unknown Source)
	at com.aspose.words.zzZVB.zzZlg(Unknown Source)
	at com.aspose.words.zzZV2.zzZkK(Unknown Source)
	at com.aspose.words.zzZV2.zzZkM(Unknown Source)
	at com.aspose.words.zzZV2.zzZAN(Unknown Source)
	at com.aspose.words.zzZV2.zzZla(Unknown Source)
	at com.aspose.words.zzZQ4.zzZ(Unknown Source)
	at com.aspose.words.zzZDS.zzZ(Unknown Source)
	at com.aspose.words.Document.zzY(Unknown Source)
	at com.aspose.words.Document.zzZ(Unknown Source)
	at com.aspose.words.Document.zzZ(Unknown Source)
	at com.aspose.words.Document.save(Unknown Source)

It seems the error was triggered by some comments. Converting the file with anything like Google doc or LibreOffice without changing anything make it work.

Is there a workaround? Could you fix it?

Thanks for your time

@hmdebenque

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-20866 . You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

1 Like