BaseUri and Local files

Hi

I’m currently evaluating the aspose componente for converting HTML Files to pdf

I read the HTML from the database from this html source (string) I generat PDF Files.

Now this HTML contains img tags . this image tags have relative file pathes for exmaple like this

<img width="991" height="296" id="_x0000_i1027" src="13000360/13000349/abc.0112360088.0112152959.jpg">

the file is located unter C:\images\13000360\13000349\abc.0112360088.0112152959.jpg

What should I do so that the files is included in the pdf ?
How should I set the basepath ?
Unfortunately the image path in the uri tag contains a Slash / not a Backslash \ like normal für file pathes. do I have to do some convesion logic ?

Hi
Thanks for your request. You should simply specify baseUri upon loading your HTML documents:
https://reference.aspose.com/words/net/aspose.words.loading/loadoptions/
Hope this helps.
Best regards,

Hi

sorry I can’t figure out how this should be formatted?

If my folder is C:\images

It doesn’t work to set “C:\images” as baseuri.
I also tried to the the base Uri to file:///C:/images
I’m assuming i should write the path in a other format?

Here my SourceCode

string htmlSource = File.ReadAllText(@"C:\temp\BildMail.HTML");
byte[] data = Encoding.Default.GetBytes(htmlSource);
 
            
using (MemoryStream sourceStream = new MemoryStream(data))
{
    LoadOptions htmlLoadOptions = new LoadOptions(LoadFormat.Html, "",  @"C:\images");
    Document doc = new Document(sourceStream);
 
    doc.Save(@"C:\temp\bild.pdf", SaveFormat.Pdf);
}

Here the Html source

<html >
<body lang="DE" link="blue" vlink="purple">
 <img width="991" height="296" id="_x0000_i1027" src="myimage.jpg">
</body>
</html>

the image is located in C:\images

Now I’ve put the html and image file in the same folder. And exporting still doesn’t incluide the image. There I set the basepath to an empty string.
When I double click the HTML File, i can see the image in the browser

Sorry my dubmness.

I didn’t pass the loadoptions to the load method…

Hi
It is perfect that you managed to resolve the problem. Please let me know if you need more assistance, I will be glad to help you.
Best regards,