input mhtml file
Volleyballclub Baustetten e. V.
.zip (41.5 KB)
AccuWeather.zip (50.3 KB)
Time con.zip (75.1 KB)
71.zip (93.7 KB)
Langur Monkey.zip (43.2 KB)
Palm (PalmDevs).zip (33.1 KB)
Welcome!.zip (21.2 KB)
109.zip (18.0 KB)
127.zip (16.4 KB)
137.zip (33.7 KB)
2.zip (73.4 KB)
38.zip (43.6 KB)
output pdf
Volleyballclub Baustetten e. V.
_word.pdf (192.0 KB)
AccuWeather_word.pdf (147.8 KB)
Time con_words.pdf (81.5 KB)
Langur Monkey_words.pdf (119.5 KB)
Palm (PalmDevs).pdf (270.2 KB)
Welcome!_words.pdf (121.6 KB)
109.pdf (67.8 KB)
127_word.pdf (76.2 KB)
137.pdf (32.3 KB)
2.pdf (243.3 KB)
38.pdf (479.3 KB)
language: java 21
aspose-words 25.2
our expectation is, the contents of output pdf should be similar to how the mhtml file appears in the web browser.
kindly help to fix this issue
@divine1
It seems you are experiencing issues with the conversion of an MHTML file to PDF, where the output does not match your expectations based on how the MHTML file appears in a web browser. This is a known issue that has been reported by other users as well.
To address this, you can follow these steps to ensure a more accurate conversion:
-
Use the Correct Library: Make sure you are using the latest version of Aspose.Words or Aspose.HTML for Java, as updates often include fixes for known issues. The issue you are facing has been logged and addressed in previous updates, so using the latest version may resolve your problem.
-
Conversion Code Example: Hereβs a simple code snippet to convert MHTML to PDF using Aspose.HTML for Java:
import com.aspose.html.*;
import com.aspose.html.saving.*;
public class MhtmlToPdf {
public static void main(String[] args) {
// Load the MHTML file
try (FileInputStream fileInputStream = new FileInputStream("input.mht")) {
// Create PdfSaveOptions
PdfSaveOptions options = new PdfSaveOptions();
// Convert MHTML to PDF
Converter.convertMHTML(fileInputStream, options, "output.pdf");
} catch (Exception e) {
e.printStackTrace();
}
}
}
-
Check Save Options: You can customize the PdfSaveOptions to better fit your needs. This includes setting page size, margins, and other rendering options that might affect the output quality.
-
Review Known Issues: If the problem persists, it may be beneficial to check the Aspose forums for similar issues. Other users have reported content loss during MHTML to PDF conversion, and the Aspose team has acknowledged these issues and is working on improvements.
If you continue to face difficulties, please consider sharing your specific MHTML file and the code you are using for further assistance.
For more detailed information on MHTML to PDF conversion, you can refer to the official documentation here and here.
Sources:
[1]: Convert MHTML to PDF in Java - Aspose.HTML for Java
[2]: MHTML Converter - Aspose.HTML for Java - Aspose Documentation
@divine1 You should note, that Aspose.Words is designed to work with MS Word documents. HTML documents and MS Word documents object models are quite different and it is not always possible to provide 100% fidelity after conversion one model to another. In most cases Aspose.Words mimics MS Word behavior when work with HTML. If you open your MHTML using MS Word you will see the similar result.
1 Like
@alexey.noskov thank you for your response.
could you recommend a aspose library for mhtml to pdf conversion?
@divine1 You can also try using Aspose.HTML for HTML to PDF conversion:
https://docs.aspose.com/html/java/html-to-pdf-converter/
1 Like
@alexey.noskov thank you for the suggestion.
i have checked it too . i have already reported couple of issues observed in aspose-html. i will be reporting few additional issues for aspose-html
1 Like