Mht to pdf, exception is thrown "Incompatible unit types."

language java 21

library
aspose-html 25.2.2

During conversion from mht to pdf, exception is thrown “Incompatible unit types.”. Output pdf gets generated but the content is getting cut. contents are missing

input file
Langur Monkey.zip (43.2 KB)

output file
Langur Monkey_html.pdf (65.3 KB)

@divine1

The exception “Incompatible unit types” during the conversion from MHT to PDF using Aspose.HTML can occur due to various reasons, such as issues with the content or styles defined in the MHT file. To address this issue and ensure that the content is not cut off in the output PDF, you can try the following steps:

  1. Check the MHT File: Ensure that the MHT file does not contain any unsupported styles or elements that might cause the conversion to fail. Sometimes, complex layouts or specific CSS properties can lead to such exceptions.

  2. Use PdfSaveOptions: When converting, you can customize the PdfSaveOptions to better handle the content. For example, you can specify page size, margins, and other settings that might help in rendering the content correctly. Here’s a basic example of how to set up the conversion:

    import com.aspose.html.converters.Converter;
    import com.aspose.html.saving.PdfSaveOptions;
    
    public class MHTToPDFConverter {
        public static void main(String[] args) {
            try (java.io.FileInputStream fileInputStream = new java.io.FileInputStream("path/to/your/file.mht")) {
                PdfSaveOptions options = new PdfSaveOptions();
                options.setJpegQuality(100); // Set JPEG quality if images are present
                // You can customize other options here as needed
    
                String outputFile = "path/to/output/file.pdf";
                Converter.convertMHTML(fileInputStream, options, outputFile);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    
  3. Update Library: Ensure that you are using the latest version of the Aspose.HTML library, as updates may include bug fixes and improvements that could resolve your issue.

  4. Review Documentation: For more detailed information on customizing the conversion process, you can refer to the official documentation on converting MHTML to PDF, which provides insights into various options available for fine-tuning the conversion.

If the problem persists after trying these steps, consider sharing the specific MHT file or a simplified version of it for further analysis, as the issue might be related to the content itself.

For more information on the conversion process, you can refer to the official documentation here.

Sources:
[1]: Convert MHTML to PDF in Java - Aspose.HTML for Java

@divine1

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): HTMLJAVA-2001

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

in aspose-html 25.3 , the attached input file in the first question is running infinitely.

this exception is which was first reported is not thrown “Incompatible unit types.” in aspose-html 25.3. but this exception was thrown in aspose-html 25.2

please fix this

@divine1

The ticket is still under the phase of investigation and it hasn’t been yet resolved. As soon as it is fixed, we will let you know via this forum thread. Please be patient and spare us some time.