Welcome Guest Search | Active Topics | Sign In | Register

Do not forget to set HtmlToPdf.Options.BaseUrl when calling ConvertHtml Options
eo_support
Posted: Friday, April 20, 2012 12:02:29 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,201
Usually you must also set HtmlToPdf.Options.BaseUrl correctly when calling ConvertHtml. Not setting BaseUrl is not a problem if your HTML only contain simple text, for example:

Code: HTML/ASPX
<b>Hello!</b>


In this case it is fine if you do not set BaseUrl.

However if your HTML contains anything that reference another resource, for example, an image:

Code: HTML/ASPX
<img src="logo.gif" />


Then the converter will need to figure out the full path of the image first. If ConvertUrl was used, then the converter would simply use the main page Url to derive the full Url for the partial resource. For example, if the main page is "http://www.essentialobjects.com/default.aspx", then a partial Url "logo.gif" will be expanded to "http://www.essentialobjects.com/logo.gif" first.

When ConvertHtml is used, the converter does not have this information about where this page originally comes from. In that case it looks for HtmlToPdf.Options.BaseUrl for that information. For example, if BaseUrl is set to "http://www.essentialobjects.com/", then partial Url "logo.gif" will be expanded to "http://www.essentialobjects.com/logo.gif" as well.

BaseUrl not only affect images, but any partial Urls, such as CSS style files, JavaScript files, etc.





You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.