Welcome Guest Search | Active Topics | Sign In | Register

ConvertHtml not loading images Options
dop66
Posted: Tuesday, May 13, 2014 6:56:07 AM
Rank: Newbie
Groups: Member

Joined: 5/8/2014
Posts: 2
Hello.

I am trying to generate a pdf file through ConverHtml.So I set baseUrl as requested and later i call ConverHtml with html code retrieved from a aspx page in page Render event:

protected override void Render(HtmlTextWriter writer)
{
StringBuilder sbOut = new StringBuilder();
StringWriter swOut = new StringWriter(sbOut);
HtmlTextWriter htwOut = new HtmlTextWriter(swOut);
base.Render(htwOut);
string html = sbOut.ToString();
writer.Write(html);

PdfDocument doc = new PdfDocument();

string baseUrl = Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/') + "/";
HtmlToPdfOptions options = new HtmlToPdfOptions();
options.BaseUrl = baseUrl;
HtmlToPdf.ConvertHtml(html, doc, options);
string pathPoliza = String.Format("{0}Poliza_{1}.pdf", ConfigurationManager.AppSettings["Url_Generacion_Ficheros"], Request["poliza"]);
doc.Save(pathPoliza);
}

A new file is created but images are not loaded, instead of them it appears some question marks(?).

What can i do to resolve image loading???

Thanks in advance.
eo_support
Posted: Tuesday, May 13, 2014 12:19:02 PM
Rank: Administration
Groups: Administration

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

Your code looks fine to us. You can try two things:

1. Check your IIS logs and see if the image Url were sent to your server and if your server was responding it correctly;
2. Check DNS issue on your server. See here for more details:
http://www.essentialobjects.com/doc/4/web/troubleshoot.aspx
3. Try to use ASPXToPDF instead of calling HtmlToPdf.ConvertHtml directly. ASPXToPDF is specifically designed to convert an ASP.NET page into PDF;

Please let us know the result.

Thanks!
dop66
Posted: Friday, May 16, 2014 7:16:49 AM
Rank: Newbie
Groups: Member

Joined: 5/8/2014
Posts: 2
Hi again,

1.There´s no log information about images loading fail.
2. That happens when we use ConvertUrl, we have to change our target url in order to generate pdf correctly, but using ConvertHtml and ASPXToPPDF it doesn't work,
3. Using that component, the result is the same, images are not loaded.

Finally, we have decided to set absolute urls for images src attribute and it works.

Thanks.
eo_support
Posted: Friday, May 16, 2014 7:53:08 AM
Rank: Administration
Groups: Administration

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

I am glad that it works with absolute path. That means you have a problem with BaseUrl. It could be that the same host name actually points to somewhere else on your server. When this happens, you will not get log entries in your IIS log since the actually request is being sent to somewhere 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.