language java 21
library
aspose-html 25.2.2
During conversion from mht to pdf, exception is thrown “No html part found!”
language java 21
library
aspose-html 25.2.2
During conversion from mht to pdf, exception is thrown “No html part found!”
The exception “No html part found!” during the conversion from MHT to PDF typically indicates that the MHT file you are trying to convert does not contain any valid HTML content. Here are some steps you can take to troubleshoot and resolve this issue:
Check the MHT File: Ensure that the MHT file you are using actually contains HTML content. You can open the MHT file in a web browser to verify that it displays correctly.
Use a Valid MHT File: If the MHT file is corrupted or improperly formatted, it may not be recognized during the conversion process. Try using a different MHT file that you know works.
Review the Conversion Code: Make sure your conversion code is set up correctly. Here’s a sample code snippet for converting an MHT file to PDF using Aspose.HTML in Java:
package com.aspose.html.examples;
public class MHTMLToPDFConverter {
@org.junit.jupiter.api.Test
public void convertMHTMLToPDF() throws Exception {
// Open the MHT file for reading
try (java.io.FileInputStream fileInputStream = new java.io.FileInputStream("path/to/your/sample.mht")) {
// Create an instance of PdfSaveOptions
com.aspose.html.saving.PdfSaveOptions options = new com.aspose.html.saving.PdfSaveOptions();
options.setJpegQuality(100); // Set JPEG quality if needed
// Convert MHTML to PDF
com.aspose.html.converters.Converter.convertMHTML(
fileInputStream,
options,
"path/to/output/MHTMLtoPDF_Output.pdf"
);
}
}
}
Check for Dependencies: Ensure that you have the correct version of the Aspose.HTML library and that all dependencies are properly included in your project.
Consult Documentation: If the issue persists, refer to the official Aspose documentation for any additional requirements or troubleshooting tips related to MHT to PDF conversion.
If you continue to experience issues, consider sharing the MHT file or additional details about your setup for further assistance.
Sources:
[1]: Examples_Java_Conversion_MHTMLtoPDF_1.java
[2]: Examples_Java_ConvertingBetweenFormats_ConvertMHTMLToPDF_ConvertMHTMLFileToPDF.java
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-2000
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.
this issue is not fixed in aspose-html 25.3
The issue is still being investigated and is not yet resolved. As soon as we make some progress towards its resolution, we will inform you. Please be patient and spare us some time. We are sorry for the inconvenience.