On 14 Jan 2013, at 09:25, nels <nbhc...@gmail.com> wrote:

> My first FOP project ... I am trying to provide near instantaneous conversion
> of XML to PDF for our users and have written a custom XSL-FO.

Welcome to FOP. 



> Having read a
> number of threads here I have seen the suggestion to replace PNG images with
> JPG. I have done this though from my timings I can't say with certainty that
> run times have reduced. I have seen other suggestions and seek some more
> information as to how to implement them - they are:
> 
> load style sheets into memory,

I guess you mean keeping in memory a javax.xml.transform.Templates object for 
each XSLT and I assume that you are embedding FOP in your application (if not, 
then it will be much faster). Using Templates is a good practice, easy to 
implement, so do it but don't expect to see big differences. Also note that 
this step is not really part of FOP. FOP consumes the XSL:FO which is the 
output of this transformation.

> use a server VM and
Yes, it will definitely help.


> don't use tables.
I am not aware of any significant performance penalty due to the usage of 
tables. For big tables, there was 
https://issues.apache.org/jira/browse/FOP-1888 which is fixed in the latest 1.1 
release.  If you really need tables for your layouts then use them and come 
back to it, if you later see that this is slow.

You will have to write at least how many pages your documents are and what you 
mean by "near instantaneous conversion". Assuming you have images and an output 
of 2-4 pages, it will be hard to get below 100ms per document, after warming 
up. Having said that, here is some other points that will help:

* Create a single org.apache.fop.apps.FopFactory and reuse it. It should be 
thread-safe and this is how you will get the best performance after rendering a 
couple of documents (warm-up)

* Make sure the JVM has enough heap (-Xmx). I would not recommend below 512MB.

* If you don't need complex script support (e.g. Arabic, Hebrew scripts), then 
use
 userAgent.setComplexScriptFeaturesEnabled(false);

* This is obvious, but use the latest FOP release.

There are some other more advanced tricks one could use. They are harder to 
implement and don't apply in all cases. For example, about 80% of the time is 
to convert from XSL:FO to FOP intermediate format and the other 20% is from the 
intermediate format to the final PDF format. So caching or producing directly 
the intermediate format is faster. This is of course FOP specific, not well 
documented and might not be compatible with past & future FOP versions.

I hope you have enough suggestions to get started,

Alexis Giotis





---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org

Reply via email to