language java 21
library
aspose-html 25.2.2
During conversion from mht to pdf, exception is thrown “Cannot read field “bds” because “” is null”
input file
2.zip (73.4 KB)
language java 21
library
aspose-html 25.2.2
During conversion from mht to pdf, exception is thrown “Cannot read field “bds” because “” is null”
input file
2.zip (73.4 KB)
The exception “Cannot read field ‘bds’ because ‘’ is null” during the conversion from MHT to PDF using Aspose.HTML can occur due to various reasons, such as issues with the input MHT file or the configuration of the conversion options.
To troubleshoot this issue, you can follow these steps:
Check the Input File: Ensure that the MHT file you are trying to convert is not corrupted and is properly formatted. You can try opening the MHT file in a web browser to verify its content.
Use Sample Code: Here is a sample code snippet that demonstrates how to convert an MHT file to PDF using Aspose.HTML. Make sure to adapt it to your specific file paths and options:
package com.aspose.html.examples;
public class MHTMLToPDFConversion {
public static void main(String[] args) {
try (java.io.FileInputStream fileInputStream = new java.io.FileInputStream("path/to/your/input.mht")) {
// Initialize PdfSaveOptions
com.aspose.html.saving.PdfSaveOptions options = new com.aspose.html.saving.PdfSaveOptions();
options.setJpegQuality(100); // Set JPEG quality if needed
// Output file path
String outputFile = "path/to/your/output.pdf";
// Convert MHTML to PDF
com.aspose.html.converters.Converter.convertMHTML(fileInputStream, options, outputFile);
} catch (Exception e) {
e.printStackTrace(); // Handle exceptions appropriately
}
}
}
Update Library: Ensure that you are using the latest version of the Aspose.HTML library, as updates may contain bug fixes and improvements that could resolve your issue.
Review Documentation: Check the official Aspose.HTML documentation for any specific requirements or limitations regarding MHT to PDF conversion.
If the problem persists after following these steps, consider reaching out to Aspose support with details about your input file and the exact code you are using 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-2005
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. please help
Sadly, the ticket could not get resolved due to other issues in the queue. As soon as we make some progress towards ticket resolution, we will inform you via this forum thread. Please be patient and spare us some time.
We are sorry for the inconvenience.