Forum How do I...?

How to invoke from WebSphere web app?

csxt
We have an application that currently generates CSS/HTML to PDF using an open source library, we'll call it PDFX for purposes of this post. But a new feature request that PDFX does not support has us evaluating PrinceXML.

This is a large enterprise J2EE6 web application running in WebSphere 8.5 which is fronted by WebSeal and the IBM/Apache HTTP server.

We were 90% successfull in generate the PDF's formatted as needed using a basic test on the command line. The remaining 10% were image references that did not render because they're on the HTTP server.

So my question is, how can Prince be invoked via the Java API from within a servlet or filter in the app? If the engine is running on the server, it would have to connect to the HTTP proxy and authenticate with WebSeal in order to resolve the resources (images and CSS file) embedded in the HTML content.

Is there an example of this someplace?

mikeday
If you run Prince from within the app, can it provide access to the images and CSS via a local file path, or an unauthenticated HTTP URL? That will simplify things.
csxt
Hi Mike, I think we can do that to handle the images. But the CSS file is embedded within our app and imported by the html the app generates. How might we resolve that? I suppose, worse case, I can make the CSS styles inline.

So, if we reference the files via the filesystem, I suppose we'd need to set the base URL to that path (e.g., prince.setBaseURL("/opt/local/software/csxinstalledApps/rb_rbms/docs_shared")?

BTW, I submitted an inquiry for purchasing licenses via your website.

Edited by csxt

mikeday
Does the CSS require authentication to access over HTTP?
csxt
Hi Mike....we were able to get it installed on our Linux server, but we're now getting the error "internal error: no available fonts". We edited the fonts.css file to map sans-serif to the font ttf file, but the error still happens.

Does that file have to be explicitly imported by our HTML content? Or do I need to tell prince to load it via the API?

Attched is the fonts.css file and here is the debug output from Prince:

Wed Nov 20 21:53:55 2013: ---- begin
Wed Nov 20 21:53:55 2013: debug: loading license: /usr/lib/prince/license/license.dat
Wed Nov 20 21:53:55 2013: loading style sheet: /usr/lib/prince/style/fonts.css
Wed Nov 20 21:53:55 2013: debug: loaded resource: /usr/lib/prince/style/fonts.css
Wed Nov 20 21:53:55 2013: debug: loaded resource: type: no
Wed Nov 20 21:53:55 2013: Loading document...
Wed Nov 20 21:53:55 2013: loading HTML5 input: -
Wed Nov 20 21:53:55 2013: debug: loaded document: -
Wed Nov 20 21:53:55 2013: debug: sniffed doctype: XHTML
Wed Nov 20 21:53:55 2013: Applying style sheets...
Wed Nov 20 21:53:55 2013: loading style sheet: /usr/lib/prince/style/xhtml-ns.css
Wed Nov 20 21:53:55 2013: debug: loaded resource: /usr/lib/prince/style/xhtml-ns.css
Wed Nov 20 21:53:55 2013: debug: loaded resource: type: no
Wed Nov 20 21:53:55 2013: loading style sheet: /usr/lib/prince/style/common.css
Wed Nov 20 21:53:55 2013: debug: loaded resource: /usr/lib/prince/style/common.css
Wed Nov 20 21:53:55 2013: debug: loaded resource: type: no
Wed Nov 20 21:53:55 2013: loading style sheet: /usr/lib/prince/style/hyph.css
Wed Nov 20 21:53:55 2013: debug: loaded resource: /usr/lib/prince/style/hyph.css
Wed Nov 20 21:53:55 2013: debug: loaded resource: type: no
Wed Nov 20 21:53:55 2013: loading style sheet: /usr/lib/prince/style/mathml.css
Wed Nov 20 21:53:55 2013: debug: loaded resource: /usr/lib/prince/style/mathml.css
Wed Nov 20 21:53:55 2013: debug: loaded resource: type: no
Wed Nov 20 21:53:55 2013: loading style sheet: /usr/lib/prince/style/svg.css
Wed Nov 20 21:53:55 2013: debug: loaded resource: /usr/lib/prince/style/svg.css
Wed Nov 20 21:53:55 2013: debug: loaded resource: type: no
Wed Nov 20 21:53:55 2013: Preparing document...
Wed Nov 20 21:53:55 2013: Converting document...
Wed Nov 20 21:53:55 2013: debug: pack
Wed Nov 20 21:53:55 2013: debug: font request: bold sans-serif
Wed Nov 20 21:53:55 2013: debug: font scan: serif
Wed Nov 20 21:53:55 2013: debug: font scan: serif, 0 matches
Wed Nov 20 21:53:55 2013: /usr/share/fonts/msttcore/trebucbd.ttf: warning: unknown file format
Wed Nov 20 21:53:55 2013: warning: no glyphs for character U+0054, fallback to '?'
Wed Nov 20 21:53:55 2013: internal error: no available fonts
Wed Nov 20 21:53:55 2013: ---- end
  1. fonts.css0.7 kB

Edited by csxt

mikeday
The easiest solution is to make sure fontconfig is installed and then install either the Microsoft Core Fonts RPM package or the DejaVu fonts package. Do you get suitable output if you run "fc-list" or "fc-list | grep Times" ?
csxt
Mike....we ended up installing just the fonts. I think we're set.