Can not convert html with barcode image to PDF

Hello support !!

We have created an HTML using barcode generator function to output base64 image and this HTML including Barcode image can display OK in browser ( edge, chrome ).

We tried to use ASPOSE.HTML to convert HTML to PDF and it seems not to convert barcode image into PDF successfully.

We have attached some related files for your reference as:

barcodeHTML01.html, IDAutomation_JavaScriptBarcode_PDF417.js ,SampleCode01

regards !!

Mason Pai 06-11-2025

@masonpai0212

It seems you’re experiencing issues with converting HTML that includes a base64-encoded barcode image into a PDF using Aspose.HTML. While the HTML renders correctly in browsers, the conversion process may not handle base64 images as expected.

Here are a few steps you can take to troubleshoot and potentially resolve the issue:

  1. Ensure Proper Encoding: Make sure that the base64 string for the barcode image is correctly formatted. It should start with the appropriate data URL prefix, such as data:image/png;base64, followed by the actual base64 data.

  2. Use HtmlLoadOptions: When converting HTML to PDF, you can use the HtmlLoadOptions class to specify various settings that might affect how resources are loaded. For instance, you can set options to manage external resources effectively.

  3. Check for Resource Loading: If the barcode image is not being included, it might be due to the way resources are being loaded. Ensure that the conversion process is set to allow inline images. You can also implement a custom resource loader if needed.

  4. Test with a Simple HTML: Create a minimal HTML file that includes just the barcode image and see if that converts successfully. This can help isolate whether the issue lies with the barcode image itself or with other parts of your HTML.

  5. Review Documentation: Check the Aspose documentation for any specific notes on handling images during HTML to PDF conversion. There may be additional parameters or settings that can help.

Here is a basic example of how to set up the conversion:

using Aspose.Html;
using Aspose.Html.Converters;

// Load the HTML file
var options = new HtmlLoadOptions();
using (var document = new Document("path/to/your/barcodeHTML01.html", options))
{
    // Save the document as PDF
    document.Save("output.pdf");
}

If these steps do not resolve your issue, consider reaching out to Aspose support with the specific HTML and JavaScript files you are using for further assistance. They may provide insights tailored to your situation.

For more detailed information on converting HTML to PDF, you can refer to the Aspose documentation on this topic.

If you continue to face challenges, please feel free to ask for more help!

barcodeHTML01.zip (15.0 KB)

@masonpai0212

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): HTMLNET-6460

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.