This is an archived forum post. The information may be outdated. Contact us if you have any questions.

Pdf does not show image

IsdGlobal wrote on 2011-05-11:

Continue testing your product and I just need to solve a problem. As I said in another post, my page is dynamically generated images and show them in two ways.
Through a page or HttpHandler.
My web development in ASP.NET 2.0, VB.NET.
These codes are used:
Dim client As New pdfcrowd.Client("xxx", "xxx")

Dim html As String = _
        '"<html><body>" & _
        "<img id=""image1"" " & _
        "src=""wfmBarCode.aspx?code=1234567890123456789012345678901234567890&amp;mode=code25&amp;text=1"" " & _
        "style=""border-width:0px;position:absolute;top:300px;left:10px;"" />" & _
        "<img id=""image2"" " & _
        "src=""~/App_Handlers/hdlGetImages.ashx?TableName=tbCompany&Id=1"" " & _
        "style=""border-width:0px;position:absolute;top:400px;left:10px;"" />" & _

Dim fs As New FileStream(HttpContext.Current.Server.MapPath("html.pdf"), FileMode.Create, FileAccess.ReadWrite)
client.convertHtml(html, fs)

In my page I see the 2 images perfectly, but in the generated pdf file, not seen.

I hope some help from you.

support wrote on 2011-05-11:
Since you use the convertHtml() method, which just uploads your HTML code, the API can't figure out where your images reside if you use relative paths. You must use absolute paths , i.e instead of
<img src=""wfmBarCode.aspx?code=123....""

<img "src=""""
IsdGlobal wrote on 2011-05-12:
It works perfectly!!

Thank you
chriscadcw wrote on 2011-07-11:

I know this string is older, but I am having an issue with getting the generated pdf to display image, even when using exact url's of the images. I am using the PHP API on a php 5.2 server setup with dreamhost. I also found that linking to the external css files, even with an exact url did not parse the CSS files so I ended up having to echo the CSS inline at the top of of the page. This document is generated dynamically based on a number of settings on the website.

I have tried the online HTML to PDF generator with no success either, the only odd thing is that if I load the HTML into the WYSIWYG's HTML code editor and then switch back to the VISUAL view, it displays the images, but when I hit the "Generate PDF" button, the images are gone in the created file.

Due to the size of the HTML document and the resulting PDF, I decided not to post them inline, I have instead uploaded them and they can be retrieved using the following links:

HTML File:
Resulting PDF:

The specific lines for the cover page images are on lines 702 & 703. If you copy the links into your web browser the images pop right up in the browser.

If you can give me some ideas on where I may be going wrong with the code that is preventing these images from appearing in the produced pdf I would greatly appreciate it.
support wrote on 2011-07-11:
Hello, the images are protected by Basic Authentication:
$ curl -I
HTTP/1.1 401 Authorization Required
Date: Mon, 11 Jul 2011 08:33:01 GMT
Server: Apache
WWW-Authenticate: Basic realm="Restricted Area"
Vary: Accept-Encoding
Content-Type: text/html; charset=iso-8859-1

You need to either move them outside the restricted area or to provide username and password:
chriscadcw wrote on 2011-07-11:
Thank you for the quick response! I can't believe I didn't think of that, I modified the .htaccess file to test it and the pictures showed up perfectly.

Awesome product + Quick Support = A winning combination in my book!