Author |
Message
|
nickkirk |
Posted: Wed Nov 03, 2010 10:49 am Post subject: Apache FOP - PDF generation in the broker |
|
|
Apprentice
Joined: 26 Sep 2008 Posts: 48
|
I am using fop-1.0.
The intension is to be able to create PDF docs using a Java Compute node.
The PDFs get converted to a BASE64 stream and sent to an external party.
I am getting an exception;
java.lang.UnsatisfiedLinkError: Can't load library: /opt/IBM/mqsi/7.0/lib/headless/libmawt.so
libmawt.xo is not at the requested directory.
Unfortunaely, I do not have root access to link to where it is ( /opt/IBM/mqsi/7.0/jre16/lib/amd64/headless ).
I have tried adding the /opt/IBM/mqsi/7.0/jre16/lib/amd64/headless path to PATH and LD_LIBRARY_PATH but with no luck.
Any help would be much appreciated.
Has anyone used FOP within the broker before ? |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Nov 03, 2010 10:53 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
libmawt sounds like it's binary support files for the Abstract Window Toolkit.
Likely you are not using a standalone version of fop, that can run in a displayless/headless mode, or you are otherwise doing something with fop to cause it to want to open up a user interface element. |
|
Back to top |
|
 |
skidewd |
Posted: Wed Nov 03, 2010 12:58 pm Post subject: Re: Apache FOP - PDF generation in the broker |
|
|
 Novice
Joined: 20 Mar 2010 Posts: 12
|
nickkirk wrote: |
I am using fop-1.0.
The intension is to be able to create PDF docs using a Java Compute node.
|
Are you trying to generate PDF docs for your flows or what else? Just as an FYI, Toolkit has an option for generating PDF docs - use toobar button next to 'print'. |
|
Back to top |
|
 |
vikasmq |
Posted: Thu Nov 04, 2010 8:15 am Post subject: |
|
|
Newbie
Joined: 17 Aug 2010 Posts: 7
|
If you called the FOP command line application from some other program, for example from Java using Runtime.exec(), it may hang while trying to write log entries to the output pipe. You have to read the FOP output regularly to empty the pipe buffer. It is best to avoid exec'ing FOP, use the library interface instead. |
|
Back to top |
|
 |
vikasmq |
Posted: Thu Nov 04, 2010 8:29 am Post subject: |
|
|
Newbie
Joined: 17 Aug 2010 Posts: 7
|
I was just hoping may be this code could help you a bit
Adding XSL tranformation (XSLT)
A common requirement is to transform an XML source to XSL-FO using an XSL transformation. It is recommended to use JAXP for this task. The following snippet shows the basic code:
private FopFactory fopFactory = FopFactory.newInstance();
private TransformerFactory tFactory = TransformerFactory.newInstance();
public void init() throws ServletException {
//Optionally customize the FopFactory and TransformerFactory here
}
[..]
//Setup a buffer to obtain the content length
ByteArrayOutputStream out = new ByteArrayOutputStream();
//Setup FOP
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out);
//Setup Transformer
Source xsltSrc = new StreamSource(new File("foo-xml2fo.xsl"));
Transformer transformer = tFactory.newTransformer(xsltSrc);
//Make sure the XSL transformation's result is piped through to FOP
Result res = new SAXResult(fop.getDefaultHandler());
//Setup input
Source src = new StreamSource(new File("foo.xml"));
//Start the transformation and rendering process
transformer.transform(src, res);
//Prepare response
response.setContentType("application/pdf");
response.setContentLength(out.size());
//Send content to Browser
response.getOutputStream().write(out.toByteArray());
response.getOutputStream().flush(); |
|
Back to top |
|
 |
JLRowe |
Posted: Wed Nov 10, 2010 5:11 am Post subject: Re: Apache FOP - PDF generation in the broker |
|
|
 Yatiri
Joined: 25 May 2002 Posts: 664 Location: South East London
|
nickkirk wrote: |
I am using fop-1.0.
The intension is to be able to create PDF docs using a Java Compute node.
The PDFs get converted to a BASE64 stream and sent to an external party.
I am getting an exception;
java.lang.UnsatisfiedLinkError: Can't load library: /opt/IBM/mqsi/7.0/lib/headless/libmawt.so
libmawt.xo is not at the requested directory.
Unfortunaely, I do not have root access to link to where it is ( /opt/IBM/mqsi/7.0/jre16/lib/amd64/headless ).
I have tried adding the /opt/IBM/mqsi/7.0/jre16/lib/amd64/headless path to PATH and LD_LIBRARY_PATH but with no luck.
Any help would be much appreciated.
Has anyone used FOP within the broker before ? |
Yes, some java libs have dependencies on AWT or Swing classes, this has also been a problem with deploying code to the google app engine which has a similar restriction. Some libraries have responded to this by refactoring out the need for AWT/Swing libraries (e.g. freemarker).
You need to look a bit further into getting the native shared libraries picked up properly, otherwise use a different library that doesn't use AWT/Swing classes. |
|
Back to top |
|
 |
|