You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by bu...@apache.org on 2002/09/03 19:03:12 UTC

DO NOT REPLY [Bug 12268] New: - FOP 0.20.4 cause PDF buffer append for each rendering.

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

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12268

FOP 0.20.4 cause PDF buffer append for each rendering.

           Summary: FOP 0.20.4 cause PDF buffer append for each rendering.
           Product: Fop
           Version: 0.20.4
          Platform: Other
        OS/Version: AIX
            Status: NEW
          Severity: Blocker
          Priority: Other
         Component: pdf renderer
        AssignedTo: fop-dev@xml.apache.org
        ReportedBy: Francis.Li@fmr.com


We just upgrade FOP 0.20.4 recently. We encounter pdf file size acumulating 
issue. We use FOP object from EJB. code is as folling 

---------------------------------------------------------------------------
package com.fmr.etad.ejb;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringReader;

import javax.ejb.CreateException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import org.apache.avalon.framework.logger.Log4JLogger;
import org.apache.fop.apps.Driver;
import org.apache.fop.apps.FOPException;
import org.apache.fop.messaging.MessageHandler;
import org.apache.log4j.Logger;
import org.xml.sax.InputSource;

/**
 * Bean implementation class for Enterprise Bean: PDFGenerator
 */
public class PDFGeneratorBean implements javax.ejb.SessionBean
{
	static
	{
		MessageHandler.setQuiet(true); // makes FOP quiet
	}
	
	private Driver driver;
	private InputSource inputSource;
	
	private javax.ejb.SessionContext mySessionCtx;
		
	/**
	 * getSessionContext
	 */
	public javax.ejb.SessionContext getSessionContext()
	{
		return mySessionCtx;
	}
	/**
	 * setSessionContext
	 */
	public void setSessionContext(javax.ejb.SessionContext ctx)
	{
		mySessionCtx = ctx;
	}
	/**
	 * ejbActivate
	 */
	public void ejbActivate()
	{
		//Logger.getLogger("Logger").debug("PDFGeneratorBean: 
ejbActivate() called");
	}
	/**
	 * ejbCreate
	 */
	public void ejbCreate() throws javax.ejb.CreateException
	{
		//Logger.getLogger("Logger").debug("PDFGeneratorBean: ejbCreate
() called");
		 
		driver = new Driver();
		
		driver.setLogger(new Log4JLogger(Logger.getLogger
("Logger.FOP")));
		
		driver.setRenderer(Driver.RENDER_PDF);
		
		inputSource = new InputSource();
	}
	
	/**
	 * ejbPassivate
	 */
	public void ejbPassivate()
	{
		//Logger.getLogger("Logger").debug("PDFGeneratorBean: 
ejbPassivate() called");
	}
	/**
	 * ejbRemove
	 */
	public void ejbRemove()
	{
		//Logger.getLogger("Logger").debug("PDFGeneratorBean: ejbRemove
() called");
	}

	/**
	* renders an FO inputsource into a PDF file 
	* 
	*/
	public byte[] renderFO(String foString)
		throws IOException, FOPException
	{  	            
		saveInput(foString);         
		System.out.println("FO file length: " + foString.length());
		ByteArrayOutputStream out = new ByteArrayOutputStream();
		inputSource.setCharacterStream(new StringReader(foString));
		
		driver.reset();
		driver.setInputSource(inputSource);
		driver.setOutputStream(out);
			
		driver.run();
		System.out.println("PDF file length: " + out.toByteArray
().length);

//		saveOutput(out.toByteArray());
		return out.toByteArray();		
		
	}
	
	private void saveInput(String string)
	{
		try
		{
			FileWriter out = new FileWriter(new File
("logs/input.fo"));
			out.write(string);
			out.close();
		}
		catch (java.io.IOException ioe)
		{
			ioe.printStackTrace();
		}
	}
	
	private void saveOutput(byte[] binary)
	{
		try
		{
			FileOutputStream out = new FileOutputStream(new File
("logs/FOoutput.pdf"));
			out.write(binary);
			out.close();
		}
		catch (java.io.IOException ioe)
		{
			ioe.printStackTrace();
		}
	}
}
---------------------------------------------------------------------------

We developed the application in WSAD (websphere studio application developer) 
there is no issue in WSAD env, but when we deplyed to linux, AIX server, we got 
pdf file size increased, everytime you access it. Somehow somewhere in the 
buffer is not clean, but the PDF result is correct although the size enlarged. 
And the size is exactly the total request PDF file summation.

We use 4.03 Websphere. We know it is certain Environment issue trigger this 
bug. we don't have this issue with 0.20.3.

If you need to have further information, please let me know. I will gather it 
for you.

Thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org