We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

HTML Img tag working with converting HTML to PDF

Hello Aspose Team,

I want to convert a html page into the pdf. Following is html code for my page.

and following is my server side code.

using System;
using Aspose.Pdf.Generator;
using System.IO;

namespace PDFGeneration
public partial class Image : System.Web.UI.Page
protected void btnCreatePDF_Click(object sender, EventArgs e) {
Pdf pdf=new Pdf();
Section section=pdf.Sections.Add();
StreamReader streamReader = File.OpenText(Server.MapPath(“Image.html”));
Text text=new Text(section,streamReader.ReadToEnd()) {IsHtmlTagSupported = true,IsHtml5Supported = true};
pdf.HtmlInfo.ImgUrl = “~/Images”;
pdf.Save(Server.MapPath(“PDF”) + @"\Image.pdf" );

Response.Write(“Pdf genreated successfully”);

PDF created successfully. But Image is not there in PDF. Let me know what I have to do for that.


Hi Jalpesh,

Thanks for using our products.

I have tested the scenario using Aspose.Pdf for .NET 7.6.0 where I have referenced one of my sample image file in HTML document and as per my observations, the image appears in resultant PDF file. I have used the same code snippet which you have shared earlier. Can you please check the image file path and see if the image actually exists on that location. We are sorry for this inconvenience.

Hello Codewarior,

I am using the same version and still not able to have image in pdf.

can you send me sample project of yours


Hi Jalpesh,

Sorry for the delayed response.

Please find attached the sample project which I have used to test the scenario. I have also attached the source HTML file which I have used for testing purposes. You may update the image file path in HTML file. Also please update the extension of attached compete.txt to compete.html.