Welcome Guest Search | Active Topics | Sign In | Register

Image is not displaying in PDF Options
Vinod
Posted: Friday, March 28, 2014 5:09:16 AM
Rank: Newbie
Groups: Member

Joined: 3/20/2014
Posts: 8
Hi,
I am researching a PDF Solution to convert SharePoint Online page to PDF. I have came across EO and trying the trial version of it. however I am facing a challenge in this as below.

I am rendering my usercontrol and create HTML. This HTML is passing to EO's HtmlToPdf.ConvertHtml function. I ahve lot of images in this html as I am using charts and grids with image. However when I get the final PDF, these images are not visible. My code is given below.

EO.Pdf.PdfDocument doc = new EO.Pdf.PdfDocument();
HtmlToPdf.Options.AutoFitX = HtmlToPdfAutoFitMode.ShrinkToFit;
HtmlToPdf.Options.AutoFitY = HtmlToPdfAutoFitMode.ShrinkToFit;
HtmlToPdf.Options.SaveImageAsJpeg = true;
HtmlToPdf.Options.GeneratePageImages = true;
HtmlToPdf.Options.BaseUrl = "http://XXXXX:3332/sites/cup/pics";
if (type == 1)
{
HtmlToPdf.Options.PageSize = EO.Pdf.PdfPageSizes.A3;
HtmlToPdf.Options.OutputArea = new RectangleF(0.5f, 0.5f, 17f, 24f);
}
else if (type == 2)
{
HtmlToPdf.Options.PageSize = EO.Pdf.PdfPageSizes.A2;
HtmlToPdf.Options.OutputArea = new RectangleF(0.5f, 0.5f, 20f, 27f);
}
//HtmlToPdfResult result = HtmlToPdf.ConvertUrl(path, doc);
HtmlToPdf.ConvertHtml(html, doc);
doc.Save(outputPath);

Please suggest a solution for this.
eo_support
Posted: Friday, March 28, 2014 9:31:01 AM
Rank: Administration
Groups: Administration

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

There are two possibilities, either your BaseUrl is wrong, or the host name specified in your BaseUrl is not reachable from your server, this is usually due to a DNS error. See here for more details:

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

Thanks!
Vinod
Posted: Monday, March 31, 2014 12:43:22 AM
Rank: Newbie
Groups: Member

Joined: 3/20/2014
Posts: 8
Thank you for the reply.
However, I was able to get the images in the pdf very first time. but after that it is not coming. So I am sure that it is EO is able to access my URL but somehow for the subsequent tries it is not able to. Have you aware about this issue?

Also we are using MS charts in our pages. While exporting to PDF with the same code, the chart images are not coming in PDF. Please help us on this too.

eo_support
Posted: Monday, March 31, 2014 10:37:11 AM
Rank: Administration
Groups: Administration

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

No. It should not have anything to do with EO.Pdf. You will want to check your IIS log to see why the image can not be accessed. There are all kind of possibilities. For example, if the image file is a temp file and for some reason that file got deleted, then obviously the image won't be rendered. Another reason is maybe it requires authentication. You can check your IIS log to see whether the request is sent to your server, and whether your server responded correctly. If the request is sent to your server and the server responded correctly, then the image should show up in the PDF.

When you use MS Chart, check if the image storage mode is set to "Session". If your image storage mode is "Session", then you have to pass the session cookie to the HTML to PDF converter. Otherwise the converter and your page will be running inside different sessions and the converter won't be able to see the image, which lives in a separate session. In that case you can either change the storage mode to "file" or "memory", or use our ASPXToPDF control. ASPXToPDF will automatically duplicate your current session cookie.

Thanks!
Vinod
Posted: Friday, April 11, 2014 6:02:06 AM
Rank: Newbie
Groups: Member

Joined: 3/20/2014
Posts: 8
Hi,
Thanks for the update. I have another question.
How to implement impersonation and create EO Session with the same user id all the time. If this successful, we can use some service account for this purpose. The reason is – Right now, EO creates the session with the existing user name and we got errors initially if the user did not have permissions to the local folder location – So we had to give “Everyone” right permissions on this folder to make it work. We should avoid this.
eo_support
Posted: Friday, April 11, 2014 9:04:08 AM
Rank: Administration
Groups: Administration

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

If you are talking about Windows authentication, then we uses your calling thread's security token to authenticate with the server. So if you want to change the user, you must change the current thread's security token. I believe you can call WindowsIdentity.Impersonate to do that.

Thanks!
Vinod
Posted: Friday, April 18, 2014 5:07:55 AM
Rank: Newbie
Groups: Member

Joined: 3/20/2014
Posts: 8
Thanks for the update. We need to export multiple pages to one pdf. we are able to achieve this with EO. The issue that we are facing is, in some pages some of the images are not present in pdf. We are calling the function from one page and giving an array of page URLs to this function for generating the PDF. Any solution for this issue?
eo_support
Posted: Friday, April 18, 2014 9:13:33 AM
Rank: Administration
Groups: Administration

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

I don't think we have any interface that would take an array of Urls. So there might be some additional code between your array of Url and us. You will want to isolate that part first and pin point the exact point of failure --- for example, does it fails to load images for a specific Url? does it only fail for some images in that Url? Once you find that out we can then go from there.

Thanks!
Vinod
Posted: Friday, April 18, 2014 9:15:43 AM
Rank: Newbie
Groups: Member

Joined: 3/20/2014
Posts: 8
Hi,
It will fail to load images for one URL also if the user clicks the export button as soon as the page opens.
eo_support
Posted: Friday, April 18, 2014 9:37:13 AM
Rank: Administration
Groups: Administration

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

You will do the same thing as we suggested early to check IIS logs to see why the images are not loaded. There are three possibilities:

1. The page that you are trying to convert does not have the image or does not have the correct image Url. You can verify this by checking the content of the page before you call our API. For example, if you call ConvertHtml, then check whether the HTML you pass to us contains the correct Url;
2. The Url points to the wrong server or points to a server that can not be correctly resolved. For example, you might have "http://testserver.com/image1.gif" in your HTML but on your network "testserver.com" points to a different server that you thought it was pointing to;
3. The Url is correct but for some reason your web server refuses to serve it. For example, if for some reason your server requires authentication but you did not provide the corresponding credential to the converter, then your web server will refuse to serve that image. You can verify if that's the case from your IIS log;

If you use ConvertHtml, you will also need to set HtmlToPdf.Options.BaseUrl correctly. So you will want to check that.

Please keep in mind that we support our product, we do not provide debugging service for your application. So you will always want to try to trace the problem back to our interface first. For example, when you say "user clicks the export button it fails", we do not know what to tell you because we don't even know what that button supposes to do in your application. On the other hand, if you say "When I call HtmlToPdf.ConvertHtml with HTML x, it fails to generate image with Url y", then we will be able to help you further. Your first question is a question that is still in your code, the second question is a question that stops on our interface. We do not know anything about your code but we know our code and what's behind our interface. So that's where you want to reach first.

Also in the future if you have a question please try to start a new thread instead of following up an existing thread unless you are sure that you and the previous user have exactly the same problem.

Thanks!
Vinod
Posted: Friday, April 18, 2014 9:39:35 AM
Rank: Newbie
Groups: Member

Joined: 3/20/2014
Posts: 8
hi,
let me give more details about this issue.
We have 5 images in a pic library out of 3 were getting loaded in pdf and 2 are not loaded. And as I said earlier, If the user wait for 3-4 seconds to load the page, then we will get all the images in the pdf.
eo_support
Posted: Friday, April 18, 2014 9:47:38 AM
Rank: Administration
Groups: Administration

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

The steps outlined in our previous reply still applies. You need to follow those steps technically and check them one by one. Like we have already said in our previous post, we do not provide debugging service for your application. So what happens in your page while user waits for 3 to 4 seconds is part of your application logic and if you believe that makes a difference, then you need to find out what difference it had made in term of our interface (for example, did the input HTML you pass to us change?). We won't investigate what happened in your page and give you any recommendation based on that. So please try to trace your question back to our interface first.

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.