java.lang.IllegalArgumentException is thrown while converting MHTML to PDF using Java

Hi I am trying to convert msg to pdf and i am getting Error Unknown Source .
i refer below mentioned link for code

Code Snippet
static void EmailToPdf(String emailPath) throws Exception

	   FileInputStream fstream=new FileInputStream(emailPath);
       MailMessage eml = MailMessage.load(fstream);
       //Save the Message to output stream in MHTML format
       ByteArrayOutputStream emlStream = new ByteArrayOutputStream();, SaveOptions.getDefaultMhtml());
       //Load the stream in Word document
       com.aspose.words.LoadOptions loadopt = new com.aspose.words.LoadOptions();
       Document doc = new Document(new ByteArrayInputStream(emlStream.toByteArray()), loadopt);
      ByteArrayOutputStream foStream = new ByteArrayOutputStream();, SaveFormat.PDF);


=====Code Error===========

java.lang.IllegalArgumentException: Invalid save format requested.
at com.aspose.words.SaveOptions.createSaveOptions(Unknown Source)
at com.aspose.words.Document.zzP(Unknown Source)
at Source)
at topdf.ConvertMsgToPdf.EmailToPdf(
at topdf.ConvertMsgToPdf.main(
----Soure Code Attached— (3.0 KB)


After verifying the issue on our end, the issue seems to be occurring when working with Aspose.Words while working with saved MHTML. I have moved this thread to concerned forum where we will respond to you as soon as possible.


We have tested the scenario using the latest version of Aspose.Words for Java 20.9 and have not faced the shared exception. So, please use Aspose.Words for Java 20.9.