Welcome Guest Search | Active Topics | Sign In | Register

Printing Imge in PDF does not work Options
SK
Posted: Wednesday, March 23, 2016 2:46:17 PM
Rank: Newbie
Groups: Member

Joined: 3/17/2016
Posts: 9
I am trying to print an html markup which consist of 2 image tags.

Quote:
var h ="<img src='https://mySite.com/Images/GetImage/J5563' />";
h+="<img src='https://mySite.com/Images/staticimage.jpg'/>";
HtmlToPdf.Options.BaseUrl = "https://mySite.com";
var pdfDoc = new PdfDocument();
HtmlToPdf.ConvertHtml(h, pdfDoc);
//now write to stream


The first image src is an endpoint in my site where Images is a controller and GetImage is an action method which accepts an id which returns the image (as response stream). Second is a the path to a physical file in my project. so when i print, the first one does not work, but the second one works. I have the first source being used across my application in web pages and it works.

What is wrong here ? Should it always be a physical file ?

EDIT : I narrowed it down. This has nothing to do with the physical file existence. It is about https. When my image url (with the action method) is non https , It works. With https, It does not!
eo_support
Posted: Wednesday, March 23, 2016 4:40:20 PM
Rank: Administration
Groups: Administration

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

Are you trying to run the conversion code on the same server? If so please check your DNS settings on your server. See here for more details:

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

If you are running the code inside the same application, just as a test, you can try to run it in a worker thread or in a separate console application to see if it works.

Thanks!
SK
Posted: Wednesday, March 23, 2016 5:02:24 PM
Rank: Newbie
Groups: Member

Joined: 3/17/2016
Posts: 9
This is in my local dev machine. My host file has "127.0.0.1 mydevlocal.myproduct.com" set and i have enabled SSL in IIS. So basically i will access the page like "https://mydevlocal.myproduct.com/myappName" in my browser. Once i am authenticated, I have access to my endpoint (Images/GetImages/blah) via https, not via http.

Is it true that EO PDF use http by default to get the images in the html content we pass to ConvertHtml method ? What if the image is accessable only via https,but not via http ?

BTW, I did set the HtmlToPdf.Options.BaseUrl to my https url.
eo_support
Posted: Wednesday, March 23, 2016 5:22:44 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
SK wrote:
This is in my local dev machine. My host file has "127.0.0.1 mydevlocal.myproduct.com" set and i have enabled SSL in IIS. So basically i will access the page like "https://mydevlocal.myproduct.com/myappName" in my browser. Once i am authenticated, I have access to my endpoint (Images/GetImages/blah) via https, not via http.

What do you mean by "once I am authenticated"? Did the same authentication process take place inside EO.Pdf as well?

SK wrote:
Is it true that EO PDF use http by default to get the images in the html content we pass to ConvertHtml method ? What if the image is accessable only via https,but not via http ?

This is false. There is no such thing as "use http by default". It uses whatever your Url specifies. If the Url of your image is https, then it will use https, if the Url of your image is http, then it will use http.

SK wrote:
I did set the HtmlToPdf.Options.BaseUrl to my https url.

BaseUrl is only used to expand a partial Url into full Url. For example, if you have <img src="GetImage/J5563" />, then BaseUrl will be used to combine with "GetImage/J5563" to form the full Url. If you are already using the full Url, then BaseUrl is not used.

Thanks!
SK
Posted: Wednesday, March 23, 2016 6:19:01 PM
Rank: Newbie
Groups: Member

Joined: 3/17/2016
Posts: 9
Thanks ! When there is an image in the html i am trying to convert , does EO pdf makes a new http/https call to get it ? I tried passing the Cookies by setting those to HtmlToPdf.Options.Cookies. But it did not help either.
eo_support
Posted: Wednesday, March 23, 2016 6:26:24 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
SK wrote:
When there is an image in the html i am trying to convert , does EO pdf makes a new http/https call to get it


Absolutely. That's exactly what it does. When that fails you won't see the image. You can use a traffic monitor to monitor the traffic and that might reveal why that is failing for you.
SK
Posted: Wednesday, March 23, 2016 7:58:51 PM
Rank: Newbie
Groups: Member

Joined: 3/17/2016
Posts: 9
Thank you. It looks like i am getting a unauthorized response for the endpoint instead of returning the image. Before making the call, I am reading System.Web.HttpContext.Current.Request.Cookies collection in my mvc action method, converting that to a collection of System.Net.Cookie's and setting that to HtmlToPdf.Options.Cookies property. Am i supposed to set any other properties ?
eo_support
Posted: Thursday, March 24, 2016 8:14:07 AM
Rank: Administration
Groups: Administration

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

You will need to find that out. We have no way to tell you what your server is not happy about and decide to refuse the request. If you have attached cookies to HtmlToPdf.Options.Cookies property but they have not reached your web server, then it's a problem on our side. If they did reach your web server but your web server is still refusing the request, then you will have to look into your web server to find out why.

Thanks!
data-labs
Posted: Wednesday, March 30, 2016 12:39:12 PM
Rank: Newbie
Groups: Member

Joined: 3/7/2016
Posts: 1
I am also faced that cookie in 2016 version is not working. 2015 is ok
eo_support
Posted: Thursday, March 31, 2016 11:18:17 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
data-labs wrote:
I am also faced that cookie in 2016 version is not working. 2015 is ok


Please update to the latest build and see if that resolves the problem. If that still does not resolve the problem, please try to isolate the problem into a test project and then send the test project to us. Please see here for more details:

http://www.essentialobjects.com/forum/test_project.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.