Forum How do I...?

Background-image not showing in PDF

JorenWillems
Hi
When I want to create a PDF of a webpage, the background-image in my header isn't there, although it is in the preview I create. Any suggestions?

Preview:



PDF:

mikeday
Can you paste your CSS?
JorenWillems
What do you mean? The css is in the webpage of which a PDF will be created.
mikeday
Yes. But if Prince isn't processing it properly, it would be helpful to see it in order to figure out why. For example, is it using the background-image property? Is there absolutely positioned content? Is Prince giving any error messages when it tries to load the image?
JorenWillems
I tried to use an image (<img src="" />) instead of a background-image --> doesn't work
All the data needed is on the pdf, except the image --> strange, solution?
mikeday
Are any error messages appearing in the Prince output log?
JorenWillems
euuhh... Where can I see/find this?
mikeday
If you're running Prince on Windows, it will be in the output log tab, on Linux or MacOS X it should print to standard error, or you can use --log=file.txt to control the destination.
JorenWillems
I get this message when I try to open Prince, I use Windows 7

mikeday
Frustrating! If you google for "COMDLG32.OCX Windows 7" you will find various solutions for this problem. In the meantime, how are you running Prince currently? From the terminal? In this case, it should be printing out any errors or warnings if it cannot load an image. What is the image format? Is it a local file?
JorenWillems
It's a png.
I do not run Prince specificly. I just add this line of code:

p = new Prince("C:/Program Files/Prince/Engine/Bin/Prince.exe")
mikeday
In that case you can use the SetLog() method to control the output of any error or warning messages. Prince should have no problem with PNG files, so either the file cannot be accessed, or there is something unusual about the CSS.
jim_albright
Prince should add it in installation. You are allowed to redistribute it.

Jim Albright
Wycliffe Bible Translators

JorenWillems
p.SetLog("log.txt");

Where can I find it?
mikeday
Perhaps use an absolute path, eg. C:\Windows\Temp\log.txt or /tmp/log.txt on Linux, otherwise it will end up in the default working directory for the web server, which depends on your installation settings. Another option is to try running Prince from the command line on your HTML input, which can simplify this kind of testing.