问题
For my project, I would like to test XEP and AH Formatter. I like FOP but in some cases it really fails (floats, crop marks, pdf/x standards, etc.) and I need to know some alternatives.
XEP
With XEP I am very close. I have copied all jars into $EXIST_HOME/lib/user
and changed the adapter in $EXIST_HOME/conf.xml
. Besides, I have uploaded the xep.xml
config file into the database.
Testing XQuery:
xquery version "3.0";
declare namespace fo = "http://46.28.111.241:8081/exist/db/apps/bunny/modules/fop";
let $config := doc('/db/apps/bunny/test/xep.xml')
let $fo := doc('/db/apps/bunny/data/test.fo')
let $pdf := xslfo:render($fo, "application/pdf", (), $config)
return response:stream-binary($pdf, "application/pdf", "output.pdf")
It throws:
exerr:ERROR org.exist.dom.persistent.NodeProxy cannot be cast to org.w3c.dom.Node [at line 7, column 13]
AH Formatter
With AH Formatter, I am lost at the moment. It does not include any specific jar file I could copy into $EXIST_HOME/lib/user
, or at least it does not seem so. On AH site there is a note about using AH Formatter on a linux machine but this remark does not help in the whole process of including that into eXist.
The installation includes several folders which are all mentioned in the run.sh
file, it is much more fragmented app than XEP.
I am testing on Ubuntu Server 14.04 and eXist-db RC01.
回答1:
eXist at the moment only supports Apache FOP or RenderX XEP.
@wolfgang-meier previously added support for Antenna House formatter (22 August 2012, git commit: ffda3b7), but he then again removed it on 12 Sept 2012 (git commit: 5a2a0aa) with the comment that it would be moved to a separate project... I cannot actually find the separate project.
If you want to use Antenna House, I would suggest contacting Wolfgang or getting the code from the relevant Git Commits.
Regards the error you have with RenderX XEP, when you get the error exerr:ERROR org.exist.dom.persistent.NodeProxy cannot be cast to org.w3c.dom.Node
there should also be an associated stack trace in your $EXIST_HOME/webapp/WEB-INF/logs/exist.log
, can you please post the relevant section of that also?
回答2:
While this is an old question, I figured I would post an alternate answer here in case in comes up in searches.
As an alternative, you could install RenderX's EnMasse (or WinMasse on Windows) which gives a SOAP interface to the formatter. Note, this can be run on any machine, it is not even required to be on the eXist server at all. EnMasse provides a SOAP port to submit your FO and get back PDF (or alternate formats). Then it is as easy as building a SOAP message and sending it to the EnMasse server.
xquery version "3.0";
declare namespace fo = "http://www.w3.org/1999/XSL/Format";
(: web address for the EnMasse server :)
let $xepsoap := 'http://www.yourserver.com:6577/fairy'
(: The base for any relative references (if any) -- cannot be empty and does not need to exist at all on the formatting server, just a path to resolve relative references :)
let $in0 := 'c:/foo.xml'
(: The base64 encoded XSL FO :)
let $in1 := util:base64-encode(serialize(doc('/db/EIDO/data/edit/_scratch/sample.fo')/fo:root))
let $soapMessage := <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:fairy="http://www.yourserver.com:6577/fairy">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<fairy:format SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<in0>{$in0}</in0>
<in1>{$in1}</in1>
</fairy:format>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
let $xepout := httpclient:post(xs:anyURI($xepsoap),$soapMessage,false(),<headers/>)
return $xepout//formatReturn/string()
In this sample code, it returns base64 encoded PDF but you get the idea, you can use with response-stream-binary() for getting the PDF back.
This can be used in very high performance environments because EnMasse can scale to use many RenderX XEP threads in multiple JVMs, cores, and even different machines.
来源:https://stackoverflow.com/questions/36421504/commercial-fo-processors-in-exist-db