Aspose.Words for Java version: com.aspose:aspose-words:21.6:jdk17
Attempting to convert an MHTML file that has a GIF background image to Word results in the following exception…
java.lang.IllegalStateException: Not expected other image formats here.
at com.aspose.words.zzZhH.zzWXs(Unknown Source)
at com.aspose.words.zzYzz.zzlx(Unknown Source)
at com.aspose.words.zzYzz.zzWXs(Unknown Source)
at com.aspose.words.zzWzE.zzGf(Unknown Source)
at com.aspose.words.zzzZ.zzWXs(Unknown Source)
at com.aspose.words.zzzZ.zzWXs(Unknown Source)
at com.aspose.words.zzYf7.zzX5D(Unknown Source)
at com.aspose.words.zzYf7.zzYKP(Unknown Source)
at com.aspose.words.zzYf7.zzWXs(Unknown Source)
at com.aspose.words.zzW4Z.zzWXs(Unknown Source)
at com.aspose.words.Document.zzYl6(Unknown Source)
at com.aspose.words.Document.zzWXs(Unknown Source)
at com.aspose.words.Document.save(Unknown Source)
at com.aspose.words.Document.save(Unknown Source)
The attached zip file contains an MHTML file that be used with the example code below to reproduce the issue.
input_mht_background.mht.zip (12.5 KB)
public class MHTBackgroundBug {
public static void main(String[] args) {
try {
// Set to the path of your Aspose license file or comment out
License pdfLicense = new License();
pdfLicense.setLicense("aspose.lic");
LoadOptions mhtLoadOptions = new LoadOptions();
mhtLoadOptions.setLoadFormat(LoadFormat.MHTML);
// Open input MHTML file
Document inputDoc = new Document("input_mht_background.mht", mhtLoadOptions);
// Save as Word
inputDoc.save("output_mht_background.doc");
} catch(Exception ex) {
System.err.printf("An exception occurred: %s%n", ex.getLocalizedMessage());
ex.printStackTrace();
System.exit(1);
}
}
}