Dear Simon,Thanks for your advise, but I found the TIFF file load the font as
below code Fop fop =
fopFactory.newFop(MimeConstants.MIME_TIFF,fopFactory.newFOUserAgent(),outputStream);
Not in the below code. FopFactory fopFactory = createFopFactory();
Is this?
------------------ ???????? ------------------
??????:
"fop-users"
<[email protected]>;
????????: 2024??6??4??(??????) ????10:19
??????: "fop-users"<[email protected]>;
????: RE: RE: Fop batch generate report performance
Hi,
What about:
FopFactory fopFactory = createFopFactory();
requestData.getData().forEach(singleData ->{
String xmlData =
convertJson2Xml(singleData);
generateFopFactory(xmlData,templates,
fopFactory);
});
Thanks
From: ???? <[email protected]>
Sent: 04 June 2024 15:12
To: fop-users <[email protected]>
Subject: Re: RE: Fop batch generate report performance
Fop fop =
fopFactory.newFop(MimeConstants.MIME_TIFF,fopFactory.newFOUserAgent(),outputStream);
I am not sure as each records need to generate one file. So??How do we use same
Fop object for each outputstream?
---Original---
From: "Simon Steiner"<[email protected]>
Date: Tue, Jun 4, 2024 22:04 PM
To: "fop-users"<[email protected]>;
Cc: "18224494266"<<[email protected]>>;
Subject: RE: Fop batch generate report performance
Hi,
What about reusing the fopfactory, 1 per thread.
Thanks
From: ???? <[email protected]>
Sent: 04 June 2024 14:49
To: fop-users <[email protected]>
Cc: 18224494266 <[email protected]>
Subject: Fop batch generate report performance
Dear Fop Docters,
I am a student of Fop. May I ask some question for run the batch reports by
Fop? Our company using the Fop to generate TIFF file. found the TIFF file
cannot load font by lazy font. So, it will load all of the config folder fonts.
<renderer mime="image/tiff">
<directory recursive = "true">/tmp/fonts</directory>
<compression>CCITT T.6</compression>
<endianness>LITTLE_ENDIAN</endianness>
</renderer>
As our company all fonts more than 200M. So, when run the batch data(which
records more 10000 each request). it mean one batch request will loop 10k times
to create 10K Fop objects( fopFactory.newFop??...????. Each record of the batch
need to load the font again. it lead to the generate is too slow.
Could you give me some advise for new Fop object Repeatedly loading fonts for
each record of one batch(one batch has 10k records need to loop).
Our found the Repeatedly loading fonts of Fop core code. As attachment picture
"Fop custom load font code.PNG".
Our service code example as below.
@Override
public boolean fopGen(RequestData requestData, Templates templates) {
// one batch loop more than 10000 records.
requestData.getData().forEach(singleData ->{
String xmlData =
convertJson2Xml(singleData);
generateFopFactory(xmlData,templates);
});
return true;
}
private void generateFopFactory(String xmlData, Templates templates){
FopFactory fopFactory = createFopFactory();
try(ByteArrayInputStream inputStream = new
ByteArrayInputStream(xmlData.getBytes());
ByteArrayOutputStream outputStream = new
ByteArrayOutputStream()){
Source src;
src = new StreamSource(inputStream);
Fop fop =
fopFactory.newFop(MimeConstants.MIME_TIFF,fopFactory.newFOUserAgent(),outputStream);
Transformer transformer =
templates.newTransformer();
final List<String> errList = new
ArrayList<>();
transformer.setErrorListener(new
FopErrorListener());
Result res = new
SAXResult(fop.getDefaultHandler());
transformer.transform(src,res);
convert2File(outputStream);
} catch (IOException e) {
e.printStackTrace();
} catch (FOPException e) {
e.printStackTrace();
} catch (TransformerConfigurationException e) {
e.printStackTrace();
} catch (TransformerException e) {
e.printStackTrace();
}
}