MHT imaging using aspose.html v24.12.2, Time con.mhtml” has an embedded png I guess and gave an exception during conversion (MHT to PDF)

This file “Time con.mhtml” has an embedded png I guess and gave an exception during conversion. Th
Time con.zip (75.1 KB)

is file throws same error in 24.11 and 24.12.

com.aspose.html.utils.ar: Failed to parse URL: /media/img/social-bttns.png?166
at com.aspose.html.utils.Y.a(Unknown Source)

at com.aspose.html.utils.Y.i(Unknown Source)

at com.aspose.html.Url.(Unknown Source)

at com.aspose.html.net.UrlResolver.resolve(Unknown Source)

at com.aspose.html.utils.lh.b(Unknown Source)

at com.aspose.html.utils.lj.a(Unknown Source)

at com.aspose.html.utils.lj.a(Unknown Source)

at com.aspose.html.utils.lB$1.c(Unknown Source)

at com.aspose.html.utils.lB$1.b(Unknown Source)

at com.aspose.html.utils.lB.initialize(Unknown Source)

at com.aspose.html.utils.lB.db(Unknown Source)

at com.aspose.html.utils.lB.dc(Unknown Source)

at com.aspose.html.utils.lx.e(Unknown Source)

at com.aspose.html.utils.akg.a(Unknown Source)

at com.aspose.html.utils.akg.a(Unknown Source)

at com.aspose.html.utils.akg.a(Unknown Source)

at com.aspose.html.utils.akg.a(Unknown Source)

at com.aspose.html.utils.akg.a(Unknown Source)

at com.aspose.html.utils.akg.a(Unknown Source)

at com.aspose.html.utils.akg.a(Unknown Source)

at com.aspose.html.utils.akg.a(Unknown Source)

at com.aspose.html.utils.Rc.a(Unknown Source)

at com.aspose.html.utils.Rc.a(Unknown Source)

at com.aspose.html.utils.Rb.a(Unknown Source)

@Ghani0303

It seems you are encountering an issue while converting an MHTML file to PDF using Aspose.HTML, specifically with an embedded PNG image. The error message indicates a failure to parse a URL, which suggests that the converter is having trouble accessing the image resource.

Here are some steps you can take to troubleshoot and potentially resolve this issue:

  1. Check Image URLs: Ensure that the URLs for the embedded images in your MHTML file are correct and accessible. If the image is hosted online, verify that the URL is valid and that there are no restrictions (like CORS) preventing access.

  2. Local Resources: If the image is supposed to be embedded, make sure that it is correctly included in the MHTML file. You can open the MHTML file in a text editor to check if the image data is present.

  3. Update Aspose.HTML: Since you mentioned that the issue persists in both versions 24.11 and 24.12, consider checking if there are any newer versions available. Sometimes, bugs are fixed in later releases.

  4. Use PdfSaveOptions: When converting, you can specify options for saving the PDF. This might help in handling resources better. Here’s a basic example of how to set up the conversion:

    using Aspose.Html.Converters;
    using Aspose.Html.Saving;
    using System.IO;
    
    public class MHTMLtoPDF
    {
        public static void Run()
        {
            string dataDir = "path_to_your_mhtml_file";
            using (FileStream fileStream = File.OpenRead(dataDir + "Time con.mhtml"))
            {
                PdfSaveOptions options = new PdfSaveOptions()
                {
                    JpegQuality = 100
                };
                Converter.ConvertMHTML(fileStream, options, "output.pdf");
            }
        }
    }
    
  5. Error Handling: Implement error handling in your code to catch exceptions and log more details about the failure. This can provide more insight into what might be going wrong.

If the problem persists after trying these steps, consider reaching out to Aspose support with the specific error message and details about your MHTML file for further assistance.

For more information on converting MHTML to PDF, you can refer to the official documentation here.

If you have any further questions or need additional help, feel free to ask!