Hi,
This the expection I get when I try to convert XSL:FO to PDF
.
The code for creation of PDF used :
*public* *void* generatePDF(String foXml)
*throws* XMLProcessingException, SAXException
{
FOUserAgent userAgent = fopFactory.newFOUserAgent();
*try
*
{
Fop processor =
fopFactory.newFop(MimeConstants.*MIME_PDF*, userAgent,
pdfStorage.getOutputHolder());
TransformerFactory factory = TransformerFactory.*newInstance*();
Transformer transformer = factory.newTransformer(); // identity transformer
//Source src = new StreamSource(new StringReader(foXml));
Result res = *new* SAXResult(processor.getDefaultHandler());
SAXSource source = *new* SAXSource(*new* InputSource(*new*StringReader(foXml)));
source.setXMLReader(XMLReaderFactory.*createXMLReader*());
transformer.transform(source, res);
}catch....
.........
...............
I have used eclipse memory analyzer tool to analyze the heap dumps created
as a result of the execption above.
On Wed, Sep 1, 2010 at 12:53 AM, Craig Ringer
<[email protected]>wrote:
> On 30/08/10 22:29, Hamed Mohammed wrote:
> > Hi,
> >
> > This is how I am using FOP to process XSL.FO <http://xsl.fo/> <
> http://XSL.FO <http://xsl.fo/>> into PDF. I
> > agree that the issue is to do with too much of memory consumption. Is
> > there a better way to process this large FO file into PDF using FOP?
>
> How much memory is too much? Have you used the JVM's tools to find out
> *where* the memory is going?
>
> If you don't know Java's profiling tools well, you might want to try the
> rather user-friendly memory profiler in NetBeans. NetBeans opens Maven
> projects directly, and can be set up for a generic Ant project quite
> quickly, so if you're not already using it there's no reason not to just
> for this.
>
> > String xml = builder.getReport(); /// gets the XSL:FO file data approx
> 50mb
>
> If you're concerned about memory consumption, writing your XSL-FO to a
> tempfile rather than an in-memory string and passing that to FOP's SAX
> engine would be a big help. Or, for that matter, writing directly to the
> SAX handler's InputStream, progressively generating the document as it's
> required so it never has to exist entirely in memory or on disk.
>
> > PdfStorage pdfHolder = pdfStorageFactory.createStorage(reportRequest,
>
> What's PdfStorage? It doesn't seem to be in fop's packages...
>
> Any chance you can post a self-contained test program that demonstrates
> the problem you describe, along with sample input for it?
>
> --
> Craig Ringer
>
> Tech-related writing: http://soapyfrogs.blogspot.com/
>
--
Thanks,
Hamed Mohammed,
Email: [email protected].