Forum How do I...?

Problems with images

okoetter
Hi,

I have a test page:
http://surveys.tnsglobal.com/wix/p1836932515.aspx?__goto=PrintStyles&r=12&s=GCWQQYWP

When I use Prince to convert it to pdf no image shows.

First I have a css background logo in the header that does not go to the pdf.
Second I replace every radiobutton and checkbox to images using jquery and those also do not show up.

Any idea what's wrong here? Using 9.0rev5.

Best regards,
Oliver
mikeday
Is the server sending back different HTML for different requests? When I save the file locally, there seems to be no problem. The link to stylesheet.aspx seems to have different parameters at the end of the URL, eg. rm=1 vs. rm=3.
okoetter
What do you mean by "save file locally"?

What we try to achieve:
This is a questionnaire and the respondent should be able to save a copy including his answers to a pdf file, so saving something locally is not an option.
We have a dedicated server with pricexml, the url is given to that web service and a pdf should be the result. I tested locally with prince.exe but don't get any images.
mikeday
Yes, I have the same problem when I run Prince on the URL that you pasted above. However, when I load that URL in the browser and save the HTML file on my local machine and run Prince on that, then it works.

Looking at the HTML, the server seems to be giving a different response depending on whether Prince is fetching it or the browser is fetching it. For example, the HTML links to a different style sheet depending on which program makes the request.
okoetter
Hmm... can I change the user agent that prince used to fetch an url?
mikeday
Not yet, but we can add an option for this soon. :)
mikeday
We have tested a new --user-agent option, and specifying the Firefox user agent string is enough to make the server deliver the correct style sheet. I can create an updated alpha build for you to try; which operating system are you running Prince on?
okoetter
Wow... what a service... that would help a lot!

On my local development version I run Windows 7 SP1 x64, don't really know what runs on our Server, must be some Windows 2003 Server variant...
mikeday
Okay here is an updated Windows build: prince-20141117-windows.zip.
It has a new --user-agent option where you can specify a browser user-agent string, eg.
prince --user-agent="Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0" ...
okoetter
Thanks a lot, I see the background image logo now.

But what does not seem to work is Javascript execution:

- the <noscript> text is shown
- the jquery script that replaces the input tags with img tags don't seem to run, I see no radio button images...

This is what I call:
prince "http://surveys.tnsglobal.com/wix/p1836932515.aspx?__goto=PrintStyles&r=12&s=GCWQQYWP" -o test.pdf -v --log log.txt --javascript --user-agent="Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0"

okoetter
Upps... my fault. Should have looked at the logs. Wrong js file, document.write is not supported.
Works fine now.