DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=29632>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=29632

Rendered reads fonts from disk everytime it renders PDF.

           Summary: Rendered reads fonts from disk everytime it renders PDF.
           Product: Fop
           Version: 0.20.4
          Platform: HP
        OS/Version: HP-UX
            Status: NEW
          Severity: Major
          Priority: Other
         Component: pdf renderer
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Even if you reuse an instance of a Driver object, renderer reads all font 
definitions (.xml) from disk everytime it processes a document. Font instances 
are not reused, a lot of memory is allocated and freed immediately, IO 
operations are huge.
You can try the following code to see how it behaves.


import org.apache.fop.configuration.ConfigurationReader;
import org.apache.fop.apps.InputHandler;
import org.apache.fop.apps.Driver;
import org.xml.sax.InputSource;

import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.*;
import java.io.*;
import java.util.Date;

public class FOP {

        public static void main(String[] args) {
                try {
                        StreamSource ss = new StreamSource(new StringReader("<< 
Put XML here >>"));
      StreamSource ss2 = new StreamSource(new StringReader("<< Put XSL here 
>>"));

                        TransformerFactory tf = TransformerFactory.newInstance
();
                        Templates ts = tf.newTemplates(ss2);
                        Transformer t = ts.newTransformer();

                        ByteArrayOutputStream resultstream = new 
ByteArrayOutputStream();

                        Result res = new StreamResult(resultstream);
                        t.transform(ss, res);

                        ConfigurationReader reader = new ConfigurationReader
(InputHandler.fileInputSource(new File("/xslconfig/conf/userconfig.xml")));

                        reader.start();

                        ByteArrayOutputStream fos = new ByteArrayOutputStream();
                        ByteArrayInputStream fis = new ByteArrayInputStream
(resultstream.toByteArray());
                        ByteArrayInputStream fis2 = new ByteArrayInputStream
(resultstream.toByteArray());
                        InputSource is = new InputSource(fis);
                        InputSource is2 = new InputSource(fis2);

                        System.out.println(new Date() + "Sleeping for 20 
seconds before first rendering, check IO read bytes now...");
                        Thread.sleep(20000);

                        Driver driver = new Driver(is, fos);
                        driver.run();

                        System.out.println(new Date() + "Sleeping for 20 
seconds after first rendering, check IO read bytes now...");
                        Thread.sleep(20000);

                        driver.setInputSource(is2);
                        driver.setOutputStream(fos);
                        driver.run();

                        System.out.println(new Date() + "Sleeping for 20 
seconds after seconds rendering, check IO read bytes now...");
                        Thread.sleep(20000);


                } catch (Exception e) {
                        e.printStackTrace();
                }

        }

}

Reply via email to