Hi Chris & John , Thanks a lot for your responses. I' m answering your questions and the info you have asked as below.
For Chris This application was developed by third party for us and delivered to us. Now since it is very slow we need to modify it to make it less memory intensive. The approach they have used is as follows. 1) The data retrieved from database is converted in to XML. 2) That XML file with the help of -it is converted in PDF. 3) The FOP version used is 0.20.4rc For John, we do have load balancing of application servers. Both the servers have single CPU and JVM size on each can be extended to 1GB at max. We have XSLT transformations also as I mentioned above in Chris's response. Do you guys think 0.20.5 will have a better performance time then 0.20.4rc. I am attaching a sample code from one of the main method which generates PDF file from our PDF Servlet. and please do suggest any alternative if you think it can be done in better way to improve processing speed. and then it is written to output as follows: byte[] content = generate(contextRoot, contextRootURL, generateParams, templateType, templateName, targetLanguage, xmlPriceBook, cover, pdfCharts, false); // session.setAttribute("LAST_PDF", content); File outFile = new File(baseDirectory + "cache/" + userProfile.getUserId() + ".pdf"); FileOutputStream fos = new FileOutputStream(outFile); fos.write(content); fos.close(); response.sendRedirect(baseHTTP_URL + "cache/" + userProfile.getUserId() + ".pdf"); Thanks and your help will be really appreciated, Jignesh ____________________Reply Separator____________________ Subject: Re: FOP being very slow. Author: [EMAIL PROTECTED] Date: 1/12/2004 9:18 AM Jignesh-NX01880 Kapadia wrote: > Hi , > We are having here. We are using FOP here for our application it generates > a 81 page PDF in the output. It takes a very long time to generate it almost > more than 1 minute. What sort of system are you running? how many CPUs, what o/s, (you mentioned memory below), and what version of FOP? The figures you quote sound reasonsable for a basic single CPU system. I dont think you can do a lot to speed up processing time for a single document. Actually I found FOP to be one of the faster XSL-FO formatters around (mainly due to the fact that keeps and other difficult features are missing) > The user acceptance criteria is 15-20 seconds for such big > PDF. if say more than 20 user try to generate the PDF file then we reach peak > with our JVM and after that no user can do anything. We are using following FOP > driver class. > > org.w3c.dom.svg.SVGDocument. I dont quite follow this bit. Are you saying you are creating SVG and XSL-FO in a DOM before presenting it to FOP for processing. This seems somewhat inefficient. > The websphere instance on which the application is running has 512MB of JVM > size. We need that application can sustain a load of 60 user at a time to > generate PDF document. The server has RAM of 3GB. The application is built with > struts. Is there any way that FOP is can be made less memory intensive? so that > it will not use much JVM but use CPU rather? There have been some changes made to improve the memory consumption of tables, but these changes have not been included in any release of FOP. You will have to download the source from CVS maintenance branch and compile it yourself. Chris --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
public synchronized byte[] generate(String contextRoot, String contextRootURL, Map generateParams, String templateType, String templateName, String targetLanguage, byte[] xmlPriceBook, String cover, String[] pdfCharts, boolean writeDebugFiles) throws java.io.FileNotFoundException, java.io.IOException, java.lang.ClassNotFoundException, javax.xml.transform.TransformerConfigurationException, javax.xml.transform.TransformerException, org.apache.fop.apps.FOPException, org.pdfbox.exceptions.COSVisitorException { writeDebugFiles = true; if (writeDebugFiles) { if (logger.isDebugEnabled()) { logger.debug("context root = " + contextRoot); } if (logger.isDebugEnabled()) { logger.debug("context root = " + contextRoot); } if (logger.isDebugEnabled()) { logger.debug("String templateType = " + (String) generateParams.get("TEMPLATE_TYPE")); } if (logger.isDebugEnabled()) { logger.debug("String templateName = " + (String) generateParams.get("TEMPLATE_NAME")); } if (logger.isDebugEnabled()) { logger.debug("String targetLanguage = " + (String) generateParams.get("TARGET_LANGUAGE")); } if (logger.isDebugEnabled()) { logger.debug("String cover = " + (String) generateParams.get("PDF_COVER")); } if (logger.isDebugEnabled()) { logger.debug("String pdfCharts = " + (String[]) generateParams.get("PDF_CHARTS")); } } String coverPath = null; if (cover != null) { if (cover.indexOf(".fo") > 0) { coverPath = contextRoot + "/xml/fo-include/" + targetLanguage + "/" + cover; } else { coverPath = contextRoot + "/xml/pdf/" + targetLanguage + "/" + cover; } } if (logger.isDebugEnabled()) { logger.debug("String coverpath = " + coverPath); } String[] chartsPaths = null; if (pdfCharts != null) { chartsPaths = new String[pdfCharts.length]; for (int i = 0; i < pdfCharts.length; i++) { chartsPaths[i] = contextRoot + "/" + pdfCharts[i]; if (logger.isDebugEnabled()) { logger.debug("String chartspath[" + i + "] = " + chartsPaths[i]); } } } FileOutputStream fos1; //if ( writeDebugFiles ){ // fos1 = new FileOutputStream(new File ("c:/debug1.xml")); // fos1.write(xmlPriceBook); // fos1.close(); //} // 1. Instantiate a TransformerFactory. javax.xml.transform.TransformerFactory tFactory = javax.xml.transform.TransformerFactory.newInstance(); // 2b. Use the TransformerFactory to process the stylesheet Source and // generate a Transformer. javax.xml.transform.Transformer transformer2 = tFactory.newTransformer(new javax.xml.transform.stream.StreamSource(new File(contextRoot + "/xml/" + targetLanguage + "/" + templateName))); transformer2.setErrorListener(new PdfErrorListener(logger)); //transformer2.setParameter("application_root", contextRoot); transformer2.setParameter("application_root", contextRootURL); System.out.println("Value of application root is" + transformer2.getParameter("application_root").toString()); // Chain these together ??? // 3b. Use the Transformer to transform an XML Source and send the // output to a Result object. ByteArrayOutputStream out2 = new ByteArrayOutputStream(); ByteArrayOutputStream out3 = new ByteArrayOutputStream(); transformer2.transform(new javax.xml.transform.stream.StreamSource( new ByteArrayInputStream(xmlPriceBook)), new javax.xml.transform.stream.StreamResult(out2)); if (writeDebugFiles) { //cut it off - unix! //fos1 = new FileOutputStream(new File("c:/debug2.xml")); //fos1.write(out2.toByteArray()); //fos1.close(); } Class.forName("org.w3c.dom.svg.SVGDocument"); // this seems to help but I don't understand how <dtt /> org.apache.fop.apps.Driver driver = new org.apache.fop.apps.Driver(); MessageHandler.setScreenLogger(logger.getAvalonLogger()); driver.setLogger(logger.getAvalonLogger()); driver.setRenderer(org.apache.fop.apps.Driver.RENDER_PDF); driver.setInputSource(new org.xml.sax.InputSource( new ByteArrayInputStream(out2.toByteArray()))); ByteArrayOutputStream baos = new ByteArrayOutputStream(); driver.setOutputStream(out3); // the response object's output stream driver.run(); //if ( writeDebugFiles ){ // fos1 = new FileOutputStream(new File ("c:/debug3.pdf")); // fos1.write(out3.toByteArray()); // fos1.close(); // if ( logger.isDebugEnabled() ) logger.debug("Saved debug3.pdf"); //} MergeCoversAndCharts mcac = new MergeCoversAndCharts(); //if ( logger.isDebugEnabled() ) logger.debug("Merging covers and charts "+coverPath); byte[] content = mcac.execute(out3.toByteArray(), coverPath, chartsPaths); //if ( writeDebugFiles ){ // fos1 = new FileOutputStream(new File ("c:/debug4.pdf")); // fos1.write(content); // fos1.close(); // if ( logger.isDebugEnabled() ) logger.debug("Saved debug4.pdf"); //} return content; }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]