Welcome Guest Search | Active Topics | Sign In | Register

HTML to PDF Images not showing Options
Gafa
Posted: Monday, May 23, 2011 9:38:24 AM
Rank: Newbie
Groups: Member

Joined: 5/23/2011
Posts: 6
How to get images to show, I don't know what image path to use.

Example:

I'm creating the HTML on the fly, it's not a html document. So I build it and then pass it in to HtmlToPdf.ConvertHtml(sHTML,sFilepathPDF);

Just and example:

string sHTML="<html><head><title></title></head><body>";

sHTML+="Hello here is an image. <img src='" + mylocalfilepath + "' />


The pdf file is created fine and the text shows but the images don't. When I check the output of the sHTML variable in VS 2010 the images display fine with the text.

Thanks

Gafa
eo_support
Posted: Monday, May 23, 2011 10:00:32 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Hi,

You will need to set HtmlToPdf.Options.BaseUrl like this:

Code: C#
//Set the "base Url" to the root directory of C drive
HtmlToPdf.Options.BaseUrl = "file:///c:/";

//Convert "c:\abc.gif" to PDF
HtmlToPdf.ConvertHtml("&lt;img src='abc.gif' /&gt;");


Note the src in your HTML only specifies the "relative path" against "base Url". Together they points to "c:\abc.gif".

This is only necessary for local files. If you are actually open a Url through a Web server, then you usually do not need to set BaseUrl.

Hope this helps. Please let us know if it works for you.

Thanks!
Gafa
Posted: Monday, May 23, 2011 10:26:59 AM
Rank: Newbie
Groups: Member

Joined: 5/23/2011
Posts: 6
Thank you it worked great.

Really like your product, very easy to use.

Gafa
eo_support
Posted: Monday, May 23, 2011 10:38:04 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Glad to hear that! Please feel free to let us know if you have any more questions.

Thanks!
Bob Pinella
Posted: Tuesday, October 14, 2014 10:58:09 AM
Rank: Member
Groups: Member

Joined: 10/14/2014
Posts: 17
I know this is an older thread but I encountered a problem with displaying images. In my case, I was trying to convert several html pages into a single PDF. Each page contained our company logo as an image. I set HtmlToPdf.Options.BaseUrl, looped through my list and created the PDF document. My image only showed up on the first page. After doing some digging, I discovered that the BaseUrl property is cleared right after you call HtmlToPdf.ConvertHtml. The solution was to set the BaseUrl in every iteration of the loop. I would imagine that this is a bug, so hopefully support can have this fixed in future versions. Thank you for such a useful, easy to use product.
eo_support
Posted: Tuesday, October 14, 2014 11:53:03 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Hi Bob,

Thanks for sharing. The behavior you observed is by design and is documented here (the last line):

http://www.essentialobjects.com/doc/4/eo.pdf.htmltopdfoptions.baseurl.aspx

Our Html to PDF converter does automatically reset certain properties after the conversion is done. The reference section for the corresponding property will tell you whether it is automatically reset or not.

Thanks!
Bob Pinella
Posted: Wednesday, October 15, 2014 3:40:45 PM
Rank: Member
Groups: Member

Joined: 10/14/2014
Posts: 17
Ok thanks for the reply - I will have to make sure to read the documentation more carefully next time!
eo_support
Posted: Thursday, October 16, 2014 12:27:41 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
No problem. Please let us know if there is anything else.

Thanks!


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.