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

Free Support Forum - aspose.com

Render local images in PDF? BaseUri - does it do anything?

Using .NET library.

Use case: we render html files, including embedded images, as part of our product. We use Aspose.HTML to convert these html “packages” into PDF format. The embedded images are gathered and placed into one directory, and we reference them in the HTML with no path (i.e. <img src='image.jpg' />).

We’ve found with some experimentation that if a referenced image is in the .NET application root then it will be rendered using the PDF convertor. While this is a good first step, we’d like to be able to use something like the HTMLDocument.BaseUri to set the default base on disk to the source directory for the images and then when rendering to PDF they will be found and imported. There’s no documentation on the BaseUri, so I can’t tell if that’s what it’s for or if I must approach this another way. I suppose I could determine the application’s execution path and add that to the html images, but that would be a much longer and more confusing approach.

What is the best way to address this need? How is the BaseUri used (or is it used?) when locating images or other linked resources?


Please use the HTMLDocument(string, string) to achieve your requirements.

// Initialize a document from the string variable
using (var document = new HTMLDocument(html_code, "C:/images/"))

If you still face problem, please ZIP and attach your code, input and expected output files here for testing. We will investigate the issue and provide you more information on it.