Hi,
I am evaluating the product and having some trouble converting HTML with relative resources.
I have the following files on a web server:
http://localhost:8080/test/index.html
http://localhost:8080/test/logo.gif
index.html:
The following all works:
Code: C#
HtmlToPdf.ConvertUrl("http://localhost:8080/test/");
HtmlToPdf.ConvertUrl("http://localhost:8080/test/index.html");
HtmlToPdf.Options.BaseUrl = "http://localhost:8080/test/";
HtmlToPdf.ConvertHtml("<img src=\"logo.gif\"/>", "out.pdf");
But this doesn't:
Code: C#
HtmlToPdf.Options.BaseUrl = "http://localhost:8080/test/index.html";
HtmlToPdf.ConvertHtml("<img src=\"logo.gif\"/>", "out.pdf");
Unfortunately I need the third case to work. It would be easy enough to change the base URL in the static case but I need to handle the general case. It looks like there is some smart URL processing in ConvertUrl which is not present in ConvertHtml.
One thing I noticed is a trailling slash after the URL when using LoadHtml. Maybe related?
Code: C#
var options = new HtmlToPdfOptions
{
BaseUrl = "http://localhost:8080/test/index.html"
};
var session = HtmlToPdfSession.Create(options);
session.LoadUrl("http://localhost:8080/test/index.html");
var url = session.GetCurrentUrl(); // http://localhost:8080/test/index.html
session.LoadHtml("<img src=\"logo.gif\"/>");
var url2 = session.GetCurrentUrl(); // http://localhost:8080/test/index.html/ (note trailing slash)