Welcome Guest Search | Active Topics | Sign In | Register

HTMLToPDF, ASP.NET- Images are not showing up when application deployed on server Options
Maitrini
Posted: Wednesday, September 19, 2012 6:52:58 PM
Rank: Newbie
Groups: Member

Joined: 8/13/2012
Posts: 5
When we deploy it on server , do we need to set base path as url path like "http://serverName:804/"
Or the files directory path like "C:\foldername\".

Below is the code that I am using

string datrStr = DateTime.Now.ToString("MM_dd_yyyy_hh_mm_ss");
string pDFFileName = @"C:\ pdfFiles\PDF" + datrStr + ".pdf";
EO.Pdf.HtmlToPdf.Options.BaseUrl = "http://localhost:2508/";

/// this code open the file in the same page and convert to pdf from html localhost: 2508
string temp = "<html><body>Image test <br /> Relative Path : <br/> <img src='/uploads/CE_N2Purge.jpg' /> </body></html>";
EO.Pdf.HtmlToPdf.ConvertHtml(temp, pDFFileName);

WebClient myWeb = new WebClient();
Byte[] myBuff = myWeb.DownloadData(pDFFileName);
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", myBuff.Length.ToString());
Response.BinaryWrite(myBuff);


So this code is working in local machine but when I deploy it to server (after changing EO.Pdf.HtmlToPdf.Options.BaseUrl = "http://serverName:805/";), it doesn’t work.

Could you please check it out and let me know what is wrong ?
eo_support
Posted: Wednesday, September 19, 2012 8:59:17 PM
Rank: Administration
Groups: Administration

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

Your BaseUrl is wrong. You need to set it to the ACTUAL BaseUrl. Whatever value you set will be used to resolve all partial Urls in your page. So if you set your BaseUrl to "http://serverName:805/", then the full Url for your image will be "http://serverName:805/uploads/CE_N2Purge.jpg". If that Url is correct on your server, then your image will show fine. If that Url is wrong (most likely that's your case), then your images won't show.

Thanks!
Maitrini
Posted: Thursday, September 20, 2012 12:58:28 PM
Rank: Newbie
Groups: Member

Joined: 8/13/2012
Posts: 5
Yes my image resides at "http://serverName:805/uploads/CE_N2Purge.jpg" . If I open this on IE I can see the image. but still it is not showing on PDF when deployed on server.
Maitrini
Posted: Thursday, September 20, 2012 1:27:33 PM
Rank: Newbie
Groups: Member

Joined: 8/13/2012
Posts: 5
FYI: I also tried below

string datrStr = DateTime.Now.ToString("MM_dd_yyyy_hh_mm_ss");
string pDFFileName = @"C:\releasenotesTemp\pdfFiles\PDF" + datrStr + ".pdf";
EO.Pdf.HtmlToPdf.Options.BaseUrl = "http://serverName:805/";

/// this code open the file in the same page and convert to pdf
string temp = "<html><body>Image test <br /> "
+"Relative Path 1(/uploads/CE_N2Purge.jpg) : <br/><br/> <img src='/uploads/CE_N2Purge.jpg' /> <br/><br/><br/>"
+"Full Path(http://serverName:805/uploads/CE_N2Purge.jpg)<br /><br/><img src='http://serverName:805/uploads/CE_N2Purge.jpg' />"

+"</body></html>";
EO.Pdf.HtmlToPdf.ConvertHtml(temp, pDFFileName);

WebClient myWeb = new WebClient();
Byte[] myBuff = myWeb.DownloadData(pDFFileName);
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", myBuff.Length.ToString());
Response.BinaryWrite(myBuff);


so i tried both realative path as well as full path ..both image didnt show up on PDF. but when I click on the full path url "'http://serverName:805/uploads/CE_N2Purge.jpg" on PDF the image opens up on the page.

Could you please let me know what could be the issue?
eo_support
Posted: Thursday, September 20, 2012 1:28:21 PM
Rank: Administration
Groups: Administration

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

You can go to your server and open the same Url from your server locally to see if you can load it.

Thanks!
Maitrini
Posted: Thursday, September 20, 2012 7:22:42 PM
Rank: Newbie
Groups: Member

Joined: 8/13/2012
Posts: 5
Yes I tried , even on server it doesnt show image in PDF. DO you think it has to do anything with security . but I can access image anywhere directly from 'http://serverName:805/uploads/CE_N2Purge.jpg. It is just not showing image on PDF
eo_support
Posted: Thursday, September 20, 2012 7:24:48 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,193
Yes. It can have to do with security. We do an HTTP get to get your image. And if your server responds fine, we will get the image. Otherwise we won't. So you may want to check your IIS log to find out why we are not getting it.

Thanks!
Maitrini
Posted: Monday, September 24, 2012 5:12:12 PM
Rank: Newbie
Groups: Member

Joined: 8/13/2012
Posts: 5
There is no error/ Exceptions caught by IIS or my application. I have also tried setting base url to http://localhost:805
instead of http://serverName:805 on the server but still dont see any image on PDF. is there any perticular permission it needs
to read image? I have tried given everyone permission , still no luck.

Could you think of anything that I am missing?
eo_support
Posted: Monday, September 24, 2012 5:46:05 PM
Rank: Administration
Groups: Administration

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

No. There is nothing else. You either didn't pass the right image Url, or you pass the right image Url but your web server is not servering it. There are no other cases that we are aware of that would make image fail to render.

Thanks!
JiBe Development Services Pvt. Ltd.
Posted: Friday, March 20, 2015 1:32:48 AM
Rank: Newbie
Groups: Member

Joined: 3/20/2015
Posts: 2
same problem here .tried everything but not working
JiBe Development Services Pvt. Ltd.
Posted: Friday, March 20, 2015 2:30:54 AM
Rank: Newbie
Groups: Member

Joined: 3/20/2015
Posts: 2
HtmlToPdf.ConvertHtml(htmlstring,filepath);
Same problem here .. I have tried all on hosted server but no success.
it is showing image in pdf file on Development and test environment.
I am using full path as source (http://serverName/images/companylogo.png) for image control.








eo_support
Posted: Friday, March 20, 2015 12:32:18 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,193
JiBe wrote:
HtmlToPdf.ConvertHtml(htmlstring,filepath);
Same problem here .. I have tried all on hosted server but no success.
it is showing image in pdf file on Development and test environment.
I am using full path as source (http://serverName/images/companylogo.png) for image control.


Try to log in into the server and access exactly that Url locally from within your server. It's very common that an Url is accessible from outside of the server but not accessible from within the server. See here for more details:

http://www.essentialobjects.com/doc/4/web/troubleshoot.aspx

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.