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

Free Support Forum - aspose.com

MHTML to PDF conversion error with URI "/" in the body

The sample document (email) has an URI “/”. An exception occurs:

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 1
at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:47)
at java.base/java.lang.String.charAt(String.java:693)
at com.aspose.words.internal.zzYfn.zzQR(Unknown Source)
at com.aspose.words.internal.zzYfn.zzYLk(Unknown Source)
at com.aspose.words.internal.zzYfn.zzX1N(Unknown Source)
at com.aspose.words.Document.save(Unknown Source)

Converter Fehler Veraktung Rendition Server.zip (54.3 KB)

public static void main( String[] args ) throws Exception {
    String source = "C:\\Ceyoniq\\Beispiele\\Fehler Veraktung Rendition Server.msg";
    try ( InputStream fis = new FileInputStream( source ) ) {
        MailMessage eml = MailMessage.load( fis );
        // save to MHTML without attachments
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        MhtSaveOptions so = SaveOptions.getDefaultMhtml();
        so.setSaveAttachments( false );
        eml.save( baos, so );

        // load MHTML to word
        LoadOptions lo = new LoadOptions();
        Document doc = new Document( new ByteArrayInputStream( baos.toByteArray() ), lo );
        doc.save("C:\\Ceyoniq\\Beispiele\\Fehler Veraktung Rendition Server.pdf", SaveFormat.PDF);

@depi Thank you for reporting this problem to us. For a sake of correction it has been logged as WORDSJAVA-2700 we will keep you informed and let you know once it is resolved.
Also I have noticed that the problem does not occur if save and load an intermediate MHTML document to file:

com.aspose.email.MailMessage eml = com.aspose.email.MailMessage.load("C:\\Temp\\in.msg");

// save to MHTML without attachments
com.aspose.email.MhtSaveOptions so = com.aspose.email.SaveOptions.getDefaultMhtml();
eml.save("C:\\Temp\\intermediate.mhtml", so);

// load MHTML to word
LoadOptions lo = new LoadOptions();

Document doc = new Document("C:\\Temp\\intermediate.mhtml");
doc.save("C:\\Temp\\out.pdf", SaveFormat.PDF);

So you can use this approach as a temporary solution.