MHT imaging using aspose.html v24.12.2, AccuWeather.mthml file conversion doesn’t work partially when tried

This file “AccuWeather.mhtml” from the attached zip gave an exception during conversion.
This file’s conversion doesn’t work partially when tried in 24.11 as well
class com.aspose.html.utils.ms.System.ArgumentException: Incompatible unit types.
com.aspose.html.utils.Y.c(Unknown Source)

com.aspose.html.utils.alp$a$1.o(Unknown Source)

com.aspose.html.utils.alp$a$1.invoke(Unknown Source)

com.aspose.html.utils.alp.i(Unknown Source)

com.aspose.html.utils.anY.aFm(Unknown Source)

com.aspose.html.utils.akB.n(Unknown Source)

com.aspose.html.utils.akB.a(Unknown Source)

com.aspose.html.utils.akB.a(Unknown Source)

com.aspose.html.utils.akB.a(Unknown Source)

com.aspose.html.utils.Si.j(Unknown Source)

com.aspose.html.utils.YN.a(Unknown Source)

com.aspose.html.rendering.MhtmlRenderer.a(Unknown Source)

com.aspose.html.rendering.MhtmlRenderer.render(Unknown Source)

com.aspose.html.rendering.MhtmlRenderer.render(Unknown Source)

com.aspose.html.utils.hK.a(Unknown Source)

com.aspose.html.utils.hK.b(Unknown Source)

com.aspose.html.utils.hK.b(Unknown Source)

com.aspose.html.converters.Converter.convertMHTML(Unknown Source)

org.conversion.EpIImgDrafting.convertMHTMLToPDF(EpIImgDrafting.java:39)

Time con.zip (75.1 KB)

@Ghani0303

It seems you are encountering an ArgumentException related to incompatible unit types while trying to convert the MHTML file “AccuWeather.mhtml” using Aspose.HTML version 24.12.2. This issue has also been observed in version 24.11.

To troubleshoot this problem, you can follow these steps:

  1. Check the MHTML File: Ensure that the MHTML file is not corrupted and is properly formatted. Sometimes, issues in the file itself can lead to conversion errors.

  2. Use the Latest Version: If you haven’t already, consider updating to the latest version of Aspose.HTML. There may have been bug fixes or improvements that address this issue.

  3. Sample Code for Conversion: Here is a sample code snippet that demonstrates how to convert an MHTML file to PDF using Aspose.HTML. You can use this as a reference to ensure your implementation is correct:

    package com.aspose.html.examples;
    
    import com.aspose.html.saving.PdfSaveOptions;
    import com.aspose.html.converters.Converter;
    
    public class MHTMLToPDFConverter {
        public static void main(String[] args) {
            try (java.io.FileInputStream fileInputStream = new java.io.FileInputStream("AccuWeather.mhtml")) {
                PdfSaveOptions options = new PdfSaveOptions();
                options.setJpegQuality(100);
                String outputFile = "MHTMLtoPDF_Output.pdf";
                Converter.convertMHTML(fileInputStream, options, outputFile);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    
  4. Review Documentation: You can refer to the official documentation for more details on the conversion process and supported features. This may provide insights into any specific requirements or limitations when working with MHTML files.

If the issue persists after trying these steps, consider reaching out to Aspose support with the specific details of the MHTML file and the error message for further assistance.

Sources:
[1]: MHTML Converter - Convert MHTML in Python - Aspose Documentation

This is the sample file
AccuWeather.zip (50.3 KB)

@Ghani0303

We used Aspose.HTML for Java 24.12.2 and below code sample. We could not replicate the exception that you mentioned.

com.aspose.html.saving.PdfSaveOptions options = new com.aspose.html.saving.PdfSaveOptions();
options.getPageSetup().setAdjustToWidestPage(true);
options.getPageSetup().getAnyPage().setMargin(new com.aspose.html.drawing.Margin(0));
options.setJpegQuality(100);
// Output file path
String outputPDF = dataDir + "output.pdf";
// Convert HTML to PDF
java.io.FileInputStream fileInputStream = new java.io.FileInputStream(dataDir + "AccuWeather.mhtml");
com.aspose.html.converters.Converter.convertMHTML(fileInputStream, options, outputPDF);

output.pdf (155.8 KB)

Can you please share what JDK you are using or any other environment details that can be useful to replicate the issue?