Forum How do I...?

getting style sheets and imaes to appear

gjardine
I'm trying to integrate prince into our (java) application. At this point I have PDF's being produced but there seems to be an
issue with setting the stylesheets. I have tried various ways of setting the base url and passing information through the addStyleSheet()
method

so for example:
prince.setBaseURL("https://d8.devdomain.com:7002/");
prince.addStyleSheet("docp/css/skins/legacy/DOFStyle.css");
or
prince.addStyleSheet("https://d8.devdomain.com:7002/docp/css/skins/legacy/DOFStyle.css");
or
prince.addStyleSheet(/export/home/mydev/dev/trunk/openInvoice/web-app/css/skins/legacy)

Also the log file indicates warning messages about the images and style sheets:

this posting in your forum seems relevant
http://www.princexml.com/bb/viewtopic.php?t=1040&highlight=cert

I took the prince source code and added this to our version of prince.java - convert method
cmdline.add("--ssl-ca-cert=/usr/local/prince-6.0r8-sol10sparc/lib/prince/ssl/curl-ca-bundle.crt");
but it did not seem to help perhaps there is something tha I need to add to the .crt file?


thanks for your help



Mon Jun 22 15:52:44 2009: ---- begin
Mon Jun 22 15:52:44 2009: -:130: error: Tag nobr invalid
Mon Jun 22 15:52:44 2009: -:131: error: Tag nobr invalid
Mon Jun 22 15:52:44 2009: -:132: error: Tag nobr invalid
Mon Jun 22 15:52:44 2009: -:133: error: Tag nobr invalid
Mon Jun 22 15:52:44 2009: -:134: error: Tag nobr invalid
Mon Jun 22 15:52:44 2009: -:135: error: Tag nobr invalid
Mon Jun 22 15:52:44 2009: -:137: error: Tag nobr invalid
Mon Jun 22 15:52:44 2009: -:158: error: Tag nobr invalid
Mon Jun 22 15:52:44 2009: -:159: error: Tag nobr invalid
Mon Jun 22 15:52:44 2009: -:1101: error: Unexpected end tag : p
Mon Jun 22 15:52:44 2009: /docp/thirdparty/yui/build/container/assets/container-core.css: warning: can't open input file: No such file or directory
Mon Jun 22 15:52:44 2009: /docp/css/skins/legacy/oiTabStyles.css: warning: can't open input file: No such file or directory
Mon Jun 22 15:52:44 2009: /docp/thirdparty/yui/build/tabview/assets/tabview-core.css: warning: can't open input file: No such file or directory
Mon Jun 22 15:52:44 2009: /docp/css/skins/legacy/AutoComplete.css: warning: can't open input file: No such file or directory
Mon Jun 22 15:52:44 2009: /docp/css/skins/legacy/overlay.css: warning: can't open input file: No such file or directory
Mon Jun 22 15:52:44 2009: /docp/css/skins/legacy/Tables.css: warning: can't open input file: No such file or directory
Mon Jun 22 15:52:44 2009: /docp/css/skins/legacy/Buttons.css: warning: can't open input file: No such file or directory
Mon Jun 22 15:52:44 2009: /docp/css/skins/legacy/StatusList.css: warning: can't open input file: No such file or directory
Mon Jun 22 15:52:44 2009: /docp/css/skins/legacy/DOFStyle.css: warning: can't open input file: No such file or directory
Mon Jun 22 15:52:44 2009: https://d8.devdomain.com:7002/docp/css/skins/legacy/DOFStyle.css: warning: SSL certificate problem, verify that the CA cert i
s OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Mon Jun 22 15:52:44 2009: /docp/css/skins/legacy/white_background_black_bottom.gif: warning: can't open input file: No such file or directory
Mon Jun 22 15:52:44 2009: /docp/media/header/oimain_wordmark_oi.gif: warning: can't open input file: No such file or directory
Mon Jun 22 15:52:44 2009: /docp/media/spacer.gif: warning: can't open input file: No such file or directory
Mon Jun 22 15:52:44 2009: /docp/media/shim.gif: warning: can't open input file: No such file or directory
Mon Jun 22 15:52:44 2009: https://d8.devdomain.com:7002/docp/media/images/collapseIcon.gif: warning: SSL certificate problem, verify that the CA cert i
s OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Mon Jun 22 15:52:44 2009: -: warning: can't open input file: No such file or directory
Mon Jun 22 15:52:45 2009: finished: success
Mon Jun 22 15:52:45 2009: ---- end
mikeday
The setBaseURL() method specifies the base URL of the document being formatted, which will affect the resolution of relative links in the document. It will not affect the addStyleSheet() method, which accepts absolute paths or URLs. I would recommend not passing relative paths to addStyleSheet(), as these may not be resolved consistently, depending on the current directory.

For the certificate error, can you try the https URL in a web browser or with curl/wget and see if they complain about the certificate? There is an undocumented Prince option --ssl-blindly-trust-server which might workaround the need for certificate verification, but we strongly discourage people using this as it defeats the whole point of using SSL in the first place.
gjardine
Ok. So it sounds like I should be calling addStylesheets like this:

prince.addStyleSheet("https://d8.devdomain.com:7002/docp/css/skins/legacy/DOFStyle.css");


The jsp's have css references like this:
/docp/css/skins/legacy/DOFStyle.css:

which produce error messages in the log file: warning: can't open input file: No such file or directory
Can I just ignore these? Since I'm trying to add them through addStyleSheet()


For the the certificate error - I can enter https://d8.devdomain.com:7002/docp/css/skins/legacy/DOFStyle.css into the browswer address
field and get the css without any issues.

We don't have curl or wget on out Solaris install.


The --ssl-blindly-trust-server option does not seem to work - I actually get a blank page when I try to run it -error log:

Wed Jun 24 16:02:42 2009: /docp/css/skins/legacy/overlay.css: warning: can't open input file: No such file or directory
Wed Jun 24 16:02:42 2009: /docp/css/skins/legacy/Tables.css: warning: can't open input file: No such file or directory
Wed Jun 24 16:02:42 2009: /docp/css/skins/legacy/Buttons.css: warning: can't open input file: No such file or directory
Wed Jun 24 16:02:42 2009: /docp/css/skins/legacy/StatusList.css: warning: can't open input file: No such file or directory
Wed Jun 24 16:02:42 2009: /docp/css/skins/legacy/DOFStyle.css: warning: can't open input file: No such file or directory
Wed Jun 24 16:02:42 2009: /docp/css/skins/legacy/white_background_black_bottom.gif: warning: can't open input file: No such file or directory
Wed Jun 24 16:02:42 2009: /docp/media/header/oimain_wordmark_oi.gif: warning: can't open input file: No such file or directory
Wed Jun 24 16:02:42 2009: /docp/media/spacer.gif: warning: can't open input file: No such file or directory
Wed Jun 24 16:02:42 2009: /docp/media/shim.gif: warning: can't open input file: No such file or directory
Wed Jun 24 16:02:42 2009: -: warning: can't open input file: No such file or directory
Wed Jun 24 16:02:43 2009: /usr/openwin/lib/X11/fonts/TTbitmaps/Arial-Bold18.pcf.Z: warning: font has no TrueType outlines
Wed Jun 24 16:02:43 2009: /usr/openwin/lib/X11/fonts/F3bitmaps/Helvetica-Narrow-Bold6.pcf.Z: warning: font has no TrueType outlines
Wed Jun 24 16:02:43 2009: warning: no glyphs for character U+0053, fallback to '?'
Wed Jun 24 16:02:43 2009: internal error: no fallback glyph for character U+0053
Wed Jun 24 16:02:43 2009: ---- end
mikeday
Now you are not getting any SSL related errors, which is good. The font errors are unrelated to SSL, and appear to be caused by Prince trying to load bitmap fonts and missing TrueType fonts with the same names. If you look in /usr/openwin/lib/X11/fonts you should be able to find some .ttf files, including TrueType fonts for Times New Roman and Arial. You may need to add @font-face rules to the default fonts.css in the lib/prince/style directory to explicitly point at these fonts, like this:
@font-face {
    font-family: Times New Roman;
    src: url("/usr/openwin/lib/X11/fonts/path/to/times.ttf")
}

with the appropriate path substituted, of course.
gjardine
thanks for the tips on the fonts.

I've been looking at the cert issue and have followed the documented solutions. I have added the cert info to the .crt that comes with prince and I'm gettting a differnet error in the logs now:

https://d8.devdomain.com:7002/docp/css/skins/legacy/oiTabStyles.css: warning: error setting certificate verify locations: C
Afile: /usr/local/prince-6.0r8-sol10sparc/lib/prince/ssl/curl-ca-bundle.crt -v CApath: none

I guess it might be a permission issue with the files? But any other info that you have would be useful

thanks
gjardine
I have added my certifcate information to the .crt file that comes with prince. This the the PEM format that has been described in previous posts (see link in this thread). I checked the permissions on the file and the entire path and it is correct. Any ideas on how to get css stylesheets to appear? I tried the "blindly accept from server" switch and I just get a blank page - no PDF at all.
mikeday
Are you still getting the font-related error messages?
gjardine
I added this to prince/style/fonts.css

@font-face {
font-family: Times New Roman;
src: url("/usr/openwin/lib/X11/fonts/TrueType/TimesNewRoman.ttf")
}
@font-face {
font-family: Arial;
src: url("/usr/openwin/lib/X11/fonts/TrueType/Arial.ttf")
}
@font-face {
font-family: Arial-Bold18;
src: url("/usr/openwin/lib/X11/fonts/TrueType/Arial-Bold.ttf")
}

Prince Error Log:
Mon Jun 29 13:50:44 2009: ---- begin
Mon Jun 29 13:50:44 2009: -:133: error: Tag nobr invalid
Mon Jun 29 13:50:44 2009: -:134: error: Tag nobr invalid
Mon Jun 29 13:50:44 2009: -:135: error: Tag nobr invalid
Mon Jun 29 13:50:44 2009: -:136: error: Tag nobr invalid
Mon Jun 29 13:50:44 2009: -:137: error: Tag nobr invalid
Mon Jun 29 13:50:44 2009: -:138: error: Tag nobr invalid
Mon Jun 29 13:50:44 2009: -:140: error: Tag nobr invalid
Mon Jun 29 13:50:44 2009: -:161: error: Tag nobr invalid
Mon Jun 29 13:50:44 2009: -:162: error: Tag nobr invalid
Mon Jun 29 13:50:44 2009: -:1177: error: Unexpected end tag : p
Mon Jun 29 13:50:44 2009: warning: failed to load external entity "javascript:false;"
Mon Jun 29 13:50:44 2009: : error: could not load input file
Mon Jun 29 13:50:45 2009: https://d8.devdomain.com:7002/: warning: The requested URL returned error: 404
Mon Jun 29 13:50:45 2009: /usr/openwin/lib/X11/fonts/TTbitmaps/Arial-Bold18.pcf.Z: warning: font has no TrueType outlines
Mon Jun 29 13:50:45 2009: /usr/openwin/lib/X11/fonts/F3bitmaps/Helvetica-Narrow-Bold6.pcf.Z: warning: font has no TrueType outlines
Mon Jun 29 13:50:45 2009: warning: no glyphs for character U+004F, fallback to '?'
Mon Jun 29 13:50:45 2009: internal error: no fallback glyph for character U+004F
Mon Jun 29 13:50:45 2009: ---- end
mikeday
Strange. What if you modify the serif and sans-serif definitions as well, so that they look like this:
@font-face {
font-family: serif;
src: url("/usr/openwin/lib/X11/fonts/TrueType/TimesNewRoman.ttf")
}

@font-face {
font-family: sans-serif;
src: url("/usr/openwin/lib/X11/fonts/TrueType/Arial.ttf")
} 

If those two files exist that should really be sufficient, one would assume.