i have Aspose.Total.Java.lic
license.
i’m trying to convert mhtml files to jpg using aspose-html
Irrespective of 24.11 or 24.12 version of Aspose.html, content keeps getting cutoff for some MHT files. There were some tweaks done in the config values for width and height, post which we were able to prevent some of the cutoff, but the converted files sometimes do not have alignments or some text boxes looking same as MHT.
what else we can tweak in configurations, the documentation given by Aspose has been tried out to the best extent.
Input –
image.png (128.9 KB)
Output –
image.png (94.3 KB)
@Ghani0303
When converting MHT files to JPG using Aspose.HTML, if you are experiencing issues with content being cut off, there are several configuration options you can adjust to improve the output quality and alignment.
-
ImageSaveOptions: Ensure you are using the ImageSaveOptions
class to specify the output format and other parameters. You can set the image format to JPG, PNG, BMP, etc. The default format is PNG, so make sure to explicitly set it to JPG if that is your desired output.
-
Page Size and Margins: You can customize the page size and margins in the ImageSaveOptions
. This is crucial for ensuring that all content fits within the output image. For example, you can set a custom page size like this:
ImageSaveOptions options = new ImageSaveOptions(ImageFormat.Jpeg);
PageSetup pageSetup = new PageSetup();
Page anyPage = new Page();
anyPage.setSize(new Size(3000, 1000)); // Set your desired width and height
pageSetup.setAnyPage(anyPage);
options.setPageSetup(pageSetup);
-
Background Color: Sometimes, setting a background color can help with visibility and alignment issues. You can specify a background color in the ImageSaveOptions
as follows:
options.setBackgroundColor(Color.getGreen()); // Set to your preferred color
-
Testing Different Configurations: Since you mentioned that some tweaks helped reduce cutoffs, continue experimenting with different values for width, height, and margins. Adjusting these parameters can significantly affect how the content is rendered.
-
Review Documentation: For more detailed information on the conversion process and available options, refer to the Aspose documentation on converting MHTML to JPG. This resource provides examples and explanations of various settings you can use to fine-tune your conversion.
By adjusting these settings, you should be able to achieve better results when converting MHT files to JPG. If issues persist, consider sharing specific examples of MHT files that are problematic, as this may help in diagnosing the issue further.
For more information, you can check the following resources:
The issue is when converting the MHT to PDF conversion
@Ghani0303
Can you please share your sample MHT file and the code snippet for our reference? We will further proceed to assist you accordingly.
Please find the sample file.
original_Calculator.net.mhtml.7z (30.1 KB)
@Ghani0303
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-1917
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.
1 Like