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

Free Support Forum - aspose.com

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



the file is located unter C:\images<b>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:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/aspose.words.loadoptionsconstructor3.html

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);
        <span style="color:blue;">using</span> (<span style="color:#2b91af;">MemoryStream</span> sourceStream = <span style="color:blue;">new</span> <span style="color:#2b91af;">MemoryStream</span>(data))
        {
            <span style="color:#2b91af;">LoadOptions</span> htmlLoadOptions = <span style="color:blue;">new</span> <span style="color:#2b91af;">LoadOptions</span>(<span style="color:#2b91af;">LoadFormat</span>.Html, <span style="color:#a31515;">""</span>,  <span style="color:#a31515;">@"C:\images"</span>);
            <span style="color:#2b91af;">Document</span> doc = <span style="color:blue;">new</span> <span style="color:#2b91af;">Document</span>(sourceStream);

            doc.Save(<span style="color:#a31515;">@"C:\temp\bild.pdf"</span>, <span style="color:#2b91af;">SaveFormat</span>.Pdf);
        }<br><br>Here the Html source<br><br><html ><br><body lang="DE" link="blue" vlink="purple"><br><img width="991" height="296" id="_x0000_i1027" src="myimage.jpg"><br></body><br></html><br><br><br>the image is located in C:\images<br><br><br></pre><br>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.<br>When I double click the HTML File, i can see the image in the browser<br>

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,