Re: Fop multiple thread generate performance

[email protected] Thu, 18 Jul 2024 08:44:31 +0200
Newsgroups gmane.text.xml.fop.user
Message-ID <[email protected]>
--------------gXNHPd0m1xmiFYdtUJK4rE1F
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

apart from the FopFactory which Simon mentioned,
I believe you can also do the same for TransformerFactory.

Also, you could consider caching the Stylesheet Templates.
They are Threadsafe & can be used by multiple Threads concurrently.

I'm a bit rusty, but below is some pseudo-code to illustrate some of that.

All the best,
Dave

packagefop.example;

importjava.io.ByteArrayInputStream;

importjava.io.File;

importjava.io.IOException;

importjava.io.InputStream;

importjava.net.URI;

importjava.util.HashMap;

importjavax.xml.transform.Templates;

importjavax.xml.transform.TransformerConfigurationException;

importjavax.xml.transform.TransformerFactory;

importjavax.xml.transform.stream.StreamSource;

importorg.apache.fop.apps.FopFactory;

importorg.apache.fop.apps.FopFactoryBuilder;

publicclassFopPseudoCode {

/*

* TODOa very simple Templates Cache. You might want to add more features 
like Timestamp checking

*/

privatestaticfinalHashMap <String, Templates> TEMPLATES_CACHE= 
newHashMap<>();

privatestaticfinalThreadLocal<TransformerFactory> LOCAL_TX_FACTORY= 
newThreadLocal<>() {

@Override

protectedTransformerFactory initialValue() {

finalTransformerFactory factory= TransformerFactory.newInstance();

/*

* TODOCustomize your factory here

*/

returnfactory;

}

};

privatestaticfinalThreadLocal<FopFactory> LOCAL_FOP_FACTORY= 
newThreadLocal<>() {

@Override

protectedFopFactory initialValue() {

finalURI defaultBaseURI= newFile(".").toURI();

returnnewFopFactoryBuilder(defaultBaseURI)

/*

* TODOCustomize your FopFactoryBuilder here

*/

.build();

}

};

publicstaticvoidmain(finalString[] args) throwsException {

finalTransformerFactory txFactory= LOCAL_TX_FACTORY.get();

finalFopFactory fopFactory= LOCAL_FOP_FACTORY.get();

finalTemplates docTemplates= readStylesheetTemplates(txFactory, 
"Invoice.xslt");

finalbyte[] docBytes= readDocBytes( "Invoice.xml");

finalbyte[] foBytes= generateFO(docBytes, docTemplates);

finalbyte[] pdfBytes= generatePDFfromFO(txFactory, foBytes, fopFactory);

}

privatestaticfinalTemplates 
readStylesheetTemplates(finalTransformerFactory factory, finalString 
fileName) throwsTransformerConfigurationException, IOException {

finalTemplates templatesCached= TEMPLATES_CACHE.get(fileName);

if(null!= templatesCached) {

returntemplatesCached;

}

try(finalInputStream ist= 
newByteArrayInputStream(readDocStylesheet(fileName)))

{

finalTemplates templatesNew= factory.newTemplates(newStreamSource(ist));

TEMPLATES_CACHE.put(fileName, templatesNew);

returntemplatesNew;

}

}

privatestaticfinalbyte[] readDocStylesheet(finalString fileName) {

return"<xsl:stylesheet>...".getBytes();

}

privatestaticfinalbyte[] readDocBytes(finalString fileName) {

return"<Invoice>...".getBytes();

}

privatestaticbyte[] generateFO(finalbyte[] xmlDataBytes, finalTemplates 
templates) {

return"<fo:root xmlns:fo=...".getBytes();

}

privatestaticbyte[] generatePDFfromFO(finalTransformerFactory factory, 
finalbyte[] bytesFO, finalFopFactory fopFactory) {

return"%PDF-1.4...".getBytes();

}

}



On 17/07/2024 08:16, Simon Steiner wrote:
>
> Hi,
>
> You can use multiple threads, each thread with their own fopfactory.
>
> Thanks
>
> *From:*Allen Wang <[email protected]>
> *Sent:* 14 July 2024 08:39
> *To:* fop-users <[email protected]>
> *Cc:* 1289495104 <[email protected]>
> *Subject:* Fop multiple thread generate performance
>
> Dear Fop Doctor.
>
> May I ask if we use mutiple thread to generate more output files. if 
> we can have any method to improve the performance.
>
> Kindly, Could you give us some advise?
>
> Thanks a lot.
>

--------------gXNHPd0m1xmiFYdtUJK4rE1F
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html>
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body>
    Hi,
    <div class="moz-forward-container"> <br>
      apart from the FopFactory which Simon mentioned,<br>
      I believe you can also do the same for TransformerFactory.<br>
      <br>
      Also, you could consider caching the Stylesheet Templates.<br>
      They are Threadsafe &amp; can be used by multiple Threads
      concurrently.<br>
      <br>
      I'm a bit rusty, but below is some pseudo-code to illustrate some
      of that.<br>
      <br>
      All the best,<br>
      Dave<br>
      <br>
      <div style="background-color:#ffffff;padding:0px 0px 0px 2px;">
        <div
style="color:#000000;background-color:#ffffff;font-family:&quot;Consolas&quot;;font-size:10pt;white-space:pre;"><div
        style="background-color:#ffffff;padding:0px 0px 0px 2px;"><div
style="color:#000000;background-color:#ffffff;font-family:&quot;Consolas&quot;;font-size:10pt;white-space:pre;"><p
        style="margin:0;"><span style="color:#7f0055;font-weight:bold;">package</span><span
        style="color:#000000;"> fop.example;</span></p><p
        style="margin:0;">
</p><p style="margin:0;"><span style="color:#7f0055;font-weight:bold;">import</span><span
        style="color:#000000;"> java.io.ByteArrayInputStream;</span></p><p
        style="margin:0;"><span style="color:#7f0055;font-weight:bold;">import</span><span
        style="color:#000000;"> java.io.File;</span></p><p
        style="margin:0;"><span style="color:#7f0055;font-weight:bold;">import</span><span
        style="color:#000000;"> java.io.IOException;</span></p><p
        style="margin:0;"><span style="color:#7f0055;font-weight:bold;">import</span><span
        style="color:#000000;"> java.io.InputStream;</span></p><p
        style="margin:0;"><span style="color:#7f0055;font-weight:bold;">import</span><span
        style="color:#000000;"> java.net.URI;</span></p><p
        style="margin:0;"><span style="color:#7f0055;font-weight:bold;">import</span><span
        style="color:#000000;"> java.util.HashMap;</span></p><p
        style="margin:0;">
</p><p style="margin:0;"><span style="color:#7f0055;font-weight:bold;">import</span><span
        style="color:#000000;"> javax.xml.transform.Templates;</span></p><p
        style="margin:0;"><span style="color:#7f0055;font-weight:bold;">import</span><span
        style="color:#000000;"> javax.xml.transform.TransformerConfigurationException;</span></p><p
        style="margin:0;"><span style="color:#7f0055;font-weight:bold;">import</span><span
        style="color:#000000;"> javax.xml.transform.TransformerFactory;</span></p><p
        style="margin:0;"><span style="color:#7f0055;font-weight:bold;">import</span><span
        style="color:#000000;"> javax.xml.transform.stream.StreamSource;</span></p><p
        style="margin:0;">
</p><p style="margin:0;"><span style="color:#7f0055;font-weight:bold;">import</span><span
        style="color:#000000;"> org.apache.fop.apps.FopFactory;</span></p><p
        style="margin:0;"><span style="color:#7f0055;font-weight:bold;">import</span><span
        style="color:#000000;"> org.apache.fop.apps.FopFactoryBuilder;</span></p><p
        style="margin:0;">
</p><p style="margin:0;"><span style="color:#7f0055;font-weight:bold;">public</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">class</span><span
        style="color:#000000;"> FopPseudoCode {</span></p><p
        style="margin:0;">
</p><p style="margin:0;"><span style="color:#000000;">    </span><span
        style="color:#3f7f5f;">/*</span></p><p style="margin:0;"><span
        style="color:#3f7f5f;">     * </span><span
        style="color:#7f9fbf;font-weight:bold;">TODO</span><span
        style="color:#3f7f5f;"> a very simple Templates Cache. You might want to add more features like Timestamp checking</span></p><p
        style="margin:0;"><span style="color:#3f7f5f;">     */</span></p><p
        style="margin:0;"><span style="color:#000000;">    </span><span
        style="color:#7f0055;font-weight:bold;">private</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">static</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;"> HashMap    &lt;String, Templates&gt;  </span><span
        style="color:#0000c0;font-style:italic;font-weight:bold;">TEMPLATES_CACHE</span><span
        style="color:#000000;">   = </span><span
        style="color:#7f0055;font-weight:bold;">new</span><span
        style="color:#000000;"> HashMap&lt;&gt;();</span></p><p
        style="margin:0;">
</p><p style="margin:0;"><span style="color:#000000;">    </span><span
        style="color:#7f0055;font-weight:bold;">private</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">static</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;"> ThreadLocal&lt;TransformerFactory&gt; </span><span
        style="color:#0000c0;font-style:italic;font-weight:bold;">LOCAL_TX_FACTORY</span><span
        style="color:#000000;">  = </span><span
        style="color:#7f0055;font-weight:bold;">new</span><span
        style="color:#000000;"> ThreadLocal&lt;&gt;() {</span></p><p
        style="margin:0;"><span style="color:#000000;">        </span><span
        style="color:#646464;">@</span><span style="color:#646464;">Override</span></p><p
        style="margin:0;"><span style="color:#000000;">        </span><span
        style="color:#7f0055;font-weight:bold;">protected</span><span
        style="color:#000000;"> TransformerFactory initialValue() {</span></p><p
        style="margin:0;"><span style="color:#000000;">            </span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;"> TransformerFactory </span><span
        style="color:#6a3e3e;">factory</span><span
        style="color:#000000;"> = TransformerFactory.</span><span
        style="color:#000000;font-style:italic;">newInstance</span><span
        style="color:#000000;">();</span></p><p style="margin:0;"><span
        style="color:#000000;">            </span><span
        style="color:#3f7f5f;">/*</span></p><p style="margin:0;"><span
        style="color:#3f7f5f;">             * </span><span
        style="color:#7f9fbf;font-weight:bold;">TODO</span><span
        style="color:#3f7f5f;"> Customize your factory here</span></p><p
        style="margin:0;"><span style="color:#3f7f5f;">             */</span></p><p
        style="margin:0;"><span style="color:#000000;">            </span><span
        style="color:#7f0055;font-weight:bold;">return</span><span
        style="color:#000000;"> </span><span style="color:#6a3e3e;">factory</span><span
        style="color:#000000;">;</span></p><p style="margin:0;"><span
        style="color:#000000;">        }</span></p><p style="margin:0;"><span
        style="color:#000000;">    };</span></p><p style="margin:0;">
</p><p style="margin:0;"><span style="color:#000000;">    </span><span
        style="color:#7f0055;font-weight:bold;">private</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">static</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;"> ThreadLocal&lt;FopFactory&gt;         </span><span
        style="color:#0000c0;font-style:italic;font-weight:bold;">LOCAL_FOP_FACTORY</span><span
        style="color:#000000;"> = </span><span
        style="color:#7f0055;font-weight:bold;">new</span><span
        style="color:#000000;"> ThreadLocal&lt;&gt;() {</span></p><p
        style="margin:0;"><span style="color:#000000;">        </span><span
        style="color:#646464;">@</span><span style="color:#646464;">Override</span></p><p
        style="margin:0;"><span style="color:#000000;">        </span><span
        style="color:#7f0055;font-weight:bold;">protected</span><span
        style="color:#000000;"> FopFactory initialValue() {</span></p><p
        style="margin:0;"><span style="color:#000000;">            </span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;"> URI                    </span><span
        style="color:#6a3e3e;">defaultBaseURI</span><span
        style="color:#000000;"> = </span><span
        style="color:#7f0055;font-weight:bold;">new</span><span
        style="color:#000000;"> File(</span><span style="color:#2a00ff;">"."</span><span
        style="color:#000000;">).toURI();</span></p><p style="margin:0;"><span
        style="color:#000000;">            </span><span
        style="color:#7f0055;font-weight:bold;">return</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">new</span><span
        style="color:#000000;"> FopFactoryBuilder(</span><span
        style="color:#6a3e3e;">defaultBaseURI</span><span
        style="color:#000000;">)</span></p><p style="margin:0;"><span
        style="color:#000000;">                    </span><span
        style="color:#3f7f5f;">/*</span></p><p style="margin:0;"><span
        style="color:#3f7f5f;">                     * </span><span
        style="color:#7f9fbf;font-weight:bold;">TODO</span><span
        style="color:#3f7f5f;"> Customize your FopFactoryBuilder here</span></p><p
        style="margin:0;"><span style="color:#3f7f5f;">                     */</span></p><p
        style="margin:0;"><span style="color:#000000;">                    .build();</span></p><p
        style="margin:0;"><span style="color:#000000;">        }</span></p><p
        style="margin:0;"><span style="color:#000000;">    };</span></p><p
        style="margin:0;">
</p><p style="margin:0;"><span style="color:#000000;">    </span><span
        style="color:#7f0055;font-weight:bold;">public</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">static</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">void</span><span
        style="color:#000000;"> main(</span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;"> String[] </span><span
        style="color:#6a3e3e;">args</span><span style="color:#000000;">) </span><span
        style="color:#7f0055;font-weight:bold;">throws</span><span
        style="color:#000000;"> Exception {</span></p><p
        style="margin:0;">
</p><p style="margin:0;"><span style="color:#000000;">        </span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;"> TransformerFactory </span><span
        style="color:#6a3e3e;">txFactory</span><span
        style="color:#000000;">    = </span><span
        style="color:#0000c0;font-style:italic;font-weight:bold;">LOCAL_TX_FACTORY</span><span
        style="color:#000000;"> .get();</span></p><p style="margin:0;"><span
        style="color:#000000;">        </span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;"> FopFactory         </span><span
        style="color:#6a3e3e;">fopFactory</span><span
        style="color:#000000;">   = </span><span
        style="color:#0000c0;font-style:italic;font-weight:bold;">LOCAL_FOP_FACTORY</span><span
        style="color:#000000;">.get();</span></p><p style="margin:0;">
</p><p style="margin:0;"><span style="color:#000000;">        </span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;"> Templates          </span><span
        style="color:#6a3e3e;">docTemplates</span><span
        style="color:#000000;"> = </span><span
        style="color:#000000;font-style:italic;">readStylesheetTemplates</span><span
        style="color:#000000;">(</span><span style="color:#6a3e3e;">txFactory</span><span
        style="color:#000000;">,  </span><span style="color:#2a00ff;">"Invoice.xslt"</span><span
        style="color:#000000;">);</span></p><p style="margin:0;"><span
        style="color:#000000;">        </span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">byte</span><span
        style="color:#000000;">[]             </span><span
        style="color:#6a3e3e;">docBytes</span><span
        style="color:#000000;">     = </span><span
        style="color:#000000;font-style:italic;">readDocBytes</span><span
        style="color:#000000;">           (            </span><span
        style="color:#2a00ff;">"Invoice.xml"</span><span
        style="color:#000000;">);</span></p><p style="margin:0;">
</p><p style="margin:0;"><span style="color:#000000;">        </span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">byte</span><span
        style="color:#000000;">[]             </span><span
        style="color:#6a3e3e;">foBytes</span><span
        style="color:#000000;">      = </span><span
        style="color:#000000;font-style:italic;">generateFO</span><span
        style="color:#000000;">             (</span><span
        style="color:#6a3e3e;">docBytes</span><span
        style="color:#000000;">,   </span><span style="color:#6a3e3e;">docTemplates</span><span
        style="color:#000000;">);</span></p><p style="margin:0;"><span
        style="color:#000000;">        </span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">byte</span><span
        style="color:#000000;">[]             </span><span
style="color:#6a3e3e;text-decoration:underline;text-decoration-color:#f4c82d;text-decoration-style:wavy;">pdfBytes</span><span
        style="color:#000000;">     = </span><span
        style="color:#000000;font-style:italic;">generatePDFfromFO</span><span
        style="color:#000000;">      (</span><span
        style="color:#6a3e3e;">txFactory</span><span
        style="color:#000000;">,  </span><span style="color:#6a3e3e;">foBytes</span><span
        style="color:#000000;">, </span><span style="color:#6a3e3e;">fopFactory</span><span
        style="color:#000000;">);</span></p><p style="margin:0;"><span
        style="color:#000000;">    }</span></p><p style="margin:0;">
</p><p style="margin:0;"><span style="color:#000000;">    </span><span
        style="color:#7f0055;font-weight:bold;">private</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">static</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;"> Templates readStylesheetTemplates(</span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;"> TransformerFactory </span><span
        style="color:#6a3e3e;">factory</span><span
        style="color:#000000;">, </span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;"> String </span><span
        style="color:#6a3e3e;">fileName</span><span
        style="color:#000000;">) </span><span
        style="color:#7f0055;font-weight:bold;">throws</span><span
        style="color:#000000;"> TransformerConfigurationException, IOException {</span></p><p
        style="margin:0;">
</p><p style="margin:0;"><span style="color:#000000;">        </span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;">      Templates   </span><span
        style="color:#6a3e3e;">templatesCached</span><span
        style="color:#000000;"> = </span><span
        style="color:#0000c0;font-style:italic;font-weight:bold;">TEMPLATES_CACHE</span><span
        style="color:#000000;">.get(</span><span style="color:#6a3e3e;">fileName</span><span
        style="color:#000000;">);</span></p><p style="margin:0;">
</p><p style="margin:0;"><span style="color:#000000;">        </span><span
        style="color:#7f0055;font-weight:bold;">if</span><span
        style="color:#000000;"> (</span><span
        style="color:#7f0055;font-weight:bold;">null</span><span
        style="color:#000000;">   !=          </span><span
        style="color:#6a3e3e;">templatesCached</span><span
        style="color:#000000;">) {</span></p><p style="margin:0;"><span
        style="color:#000000;">            </span><span
        style="color:#7f0055;font-weight:bold;">return</span><span
        style="color:#000000;">             </span><span
        style="color:#6a3e3e;">templatesCached</span><span
        style="color:#000000;">;</span></p><p style="margin:0;"><span
        style="color:#000000;">        }</span></p><p style="margin:0;">
</p><p style="margin:0;"><span style="color:#000000;">        </span><span
        style="color:#7f0055;font-weight:bold;">try</span><span
        style="color:#000000;"> (</span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;"> InputStream </span><span
        style="color:#6a3e3e;">ist</span><span style="color:#000000;">             = </span><span
        style="color:#7f0055;font-weight:bold;">new</span><span
        style="color:#000000;"> ByteArrayInputStream(</span><span
        style="color:#000000;font-style:italic;">readDocStylesheet</span><span
        style="color:#000000;">(</span><span style="color:#6a3e3e;">fileName</span><span
        style="color:#000000;">)))</span></p><p style="margin:0;"><span
        style="color:#000000;">        {</span></p><p style="margin:0;"><span
        style="color:#000000;">            </span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;">  Templates   </span><span
        style="color:#6a3e3e;">templatesNew</span><span
        style="color:#000000;">    = </span><span style="color:#6a3e3e;">factory</span><span
        style="color:#000000;">.newTemplates(</span><span
        style="color:#7f0055;font-weight:bold;">new</span><span
        style="color:#000000;"> StreamSource(</span><span
        style="color:#6a3e3e;">ist</span><span style="color:#000000;">));</span></p><p
        style="margin:0;">
</p><p style="margin:0;"><span style="color:#000000;">            </span><span
        style="color:#0000c0;font-style:italic;font-weight:bold;">TEMPLATES_CACHE</span><span
        style="color:#000000;">.put(</span><span style="color:#6a3e3e;">fileName</span><span
        style="color:#000000;">, </span><span style="color:#6a3e3e;">templatesNew</span><span
        style="color:#000000;">);</span></p><p style="margin:0;">
</p><p style="margin:0;"><span style="color:#000000;">            </span><span
        style="color:#7f0055;font-weight:bold;">return</span><span
        style="color:#000000;">                        </span><span
        style="color:#6a3e3e;">templatesNew</span><span
        style="color:#000000;">;</span></p><p style="margin:0;"><span
        style="color:#000000;">        }</span></p><p style="margin:0;"><span
        style="color:#000000;">    }</span></p><p style="margin:0;">
</p><p style="margin:0;"><span style="color:#000000;">    </span><span
        style="color:#7f0055;font-weight:bold;">private</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">static</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">byte</span><span
        style="color:#000000;">[] readDocStylesheet(</span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;"> String </span><span
        style="color:#6a3e3e;">fileName</span><span
        style="color:#000000;">) {</span></p><p style="margin:0;"><span
        style="color:#000000;">        </span><span
        style="color:#7f0055;font-weight:bold;">return</span><span
        style="color:#000000;"> </span><span style="color:#2a00ff;">"&lt;xsl:stylesheet&gt;..."</span><span
        style="color:#000000;">.getBytes();</span></p><p
        style="margin:0;"><span style="color:#000000;">    }</span></p><p
        style="margin:0;">
</p><p style="margin:0;"><span style="color:#000000;">    </span><span
        style="color:#7f0055;font-weight:bold;">private</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">static</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">byte</span><span
        style="color:#000000;">[] readDocBytes(</span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;"> String </span><span
        style="color:#6a3e3e;">fileName</span><span
        style="color:#000000;">) {</span></p><p style="margin:0;"><span
        style="color:#000000;">        </span><span
        style="color:#7f0055;font-weight:bold;">return</span><span
        style="color:#000000;"> </span><span style="color:#2a00ff;">"&lt;Invoice&gt;..."</span><span
        style="color:#000000;">.getBytes();</span></p><p
        style="margin:0;"><span style="color:#000000;">    }</span></p><p
        style="margin:0;">
</p><p style="margin:0;"><span style="color:#000000;">    </span><span
        style="color:#7f0055;font-weight:bold;">private</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">static</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">byte</span><span
        style="color:#000000;">[] generateFO(</span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">byte</span><span
        style="color:#000000;">[] </span><span style="color:#6a3e3e;">xmlDataBytes</span><span
        style="color:#000000;">, </span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;"> Templates </span><span
        style="color:#6a3e3e;">templates</span><span
        style="color:#000000;">) {</span></p><p style="margin:0;"><span
        style="color:#000000;">        </span><span
        style="color:#7f0055;font-weight:bold;">return</span><span
        style="color:#000000;"> </span><span style="color:#2a00ff;">"&lt;fo:root xmlns:fo=..."</span><span
        style="color:#000000;">.getBytes();</span></p><p
        style="margin:0;"><span style="color:#000000;">    }</span></p><p
        style="margin:0;">
</p><p style="margin:0;"><span style="color:#000000;">    </span><span
        style="color:#7f0055;font-weight:bold;">private</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">static</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">byte</span><span
        style="color:#000000;">[] generatePDFfromFO(</span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;"> TransformerFactory </span><span
        style="color:#6a3e3e;">factory</span><span
        style="color:#000000;">, </span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;"> </span><span
        style="color:#7f0055;font-weight:bold;">byte</span><span
        style="color:#000000;">[] </span><span style="color:#6a3e3e;">bytesFO</span><span
        style="color:#000000;">, </span><span
        style="color:#7f0055;font-weight:bold;">final</span><span
        style="color:#000000;"> FopFactory </span><span
        style="color:#6a3e3e;">fopFactory</span><span
        style="color:#000000;">) {</span></p><p style="margin:0;"><span
        style="color:#000000;">        </span><span
        style="color:#7f0055;font-weight:bold;">return</span><span
        style="color:#000000;"> </span><span style="color:#2a00ff;">"%PDF-1.4..."</span><span
        style="color:#000000;">.getBytes();</span></p><p
        style="margin:0;"><span style="color:#000000;">    }</span></p><p
        style="margin:0;"><span style="color:#000000;">}</span></p><p
        style="margin:0;">
</p></div></div></div>
      </div>
      <br>
      <br>
      <div class="moz-cite-prefix">On 17/07/2024 08:16, Simon Steiner
        wrote:<br>
      </div>
      <blockquote type="cite"
        cite="mid:[email protected]">
        <meta http-equiv="Content-Type"
          content="text/html; charset=UTF-8">
        <meta name="Generator"
          content="Microsoft Word 15 (filtered medium)">
        <style>@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;}span.EmailStyle18
	{mso-style-type:personal-reply;
	font-family:"Calibri",sans-serif;
	color:windowtext;}.MsoChpDefault
	{mso-style-type:export-only;
	font-family:"Calibri",sans-serif;
	mso-fareast-language:EN-US;}div.WordSection1
	{page:WordSection1;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
        <div class="WordSection1">
          <p class="MsoNormal"><span style="mso-fareast-language:EN-US">Hi,<o:p></o:p></span></p>
          <p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
          <p class="MsoNormal"><span style="mso-fareast-language:EN-US">You
              can use multiple threads, each thread with their own
              fopfactory.<o:p></o:p></span></p>
          <p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
          <p class="MsoNormal"><span style="mso-fareast-language:EN-US">Thanks<o:p></o:p></span></p>
          <p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
          <p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span
              lang="EN-US"> Allen Wang <a class="moz-txt-link-rfc2396E"
                href="mailto:[email protected]"
                moz-do-not-send="true">&lt;[email protected]&gt;</a>
              <br>
              <b>Sent:</b> 14 July 2024 08:39<br>
              <b>To:</b> fop-users <a class="moz-txt-link-rfc2396E"
                href="mailto:[email protected]"
                moz-do-not-send="true">&lt;[email protected]&gt;</a><br>
              <b>Cc:</b> 1289495104 <a class="moz-txt-link-rfc2396E"
                href="mailto:[email protected]" moz-do-not-send="true">&lt;[email protected]&gt;</a><br>
              <b>Subject:</b> Fop multiple thread generate performance<o:p></o:p></span></p>
          <p class="MsoNormal"><o:p> </o:p></p>
          <div>
            <p class="MsoNormal">Dear Fop Doctor.<o:p></o:p></p>
          </div>
          <div>
            <p class="MsoNormal"><o:p> </o:p></p>
          </div>
          <div>
            <p class="MsoNormal">May I ask if we use mutiple thread to
              generate more output files. if we can have any method to
              improve the performance.<o:p></o:p></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-bottom:12.0pt">Kindly,
              Could you give us some advise?<o:p></o:p></p>
          </div>
          <div>
            <p class="MsoNormal">Thanks a lot.<o:p></o:p></p>
          </div>
        </div>
      </blockquote>
      <br>
    </div>
  </body>
</html>

--------------gXNHPd0m1xmiFYdtUJK4rE1F--