Dear All,

in my project I need to convert 2 svg files into a single PDF file.

1) The first approach was to wrap SVG files by FO code and generate the PDF
output via Apache FOP. It works fine, but recently I've found that FOP is
somehow leaking and does not release objects properly so this solution ends
very quickly with heap space memory errors.

2) The second approach was to use Batik's PDF transcoder to produce two
separate single page PDF files and merge them using the Apache PDFBox
library.

Unfortunately, this solution is very slow, especially the Transcoder's
transcode method:

private static byte[] getPDFByteArray(InputStream svgStream) throws
Exception {
   Transcoder t = new PDFTranscoder();
   TranscoderInput input = new TranscoderInput(svgStream);

   ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
   BufferedOutputStream outputBuff = new BufferedOutputStream(outputStream);
   TranscoderOutput output = new TranscoderOutput(outputBuff);
   t.transcode(input, output);

   return outputStream.toByteArray();
}

While the first approach needs approx 2 seconds to complete the task (SVG
files are quite complex), the second solution takes approx 8 seconds on my
computer (transcode method itself 7 seconds).

Does anybody have any hint how to improve the performance of my code? Are
there any secret speed up switches?

Thanks,

Jan


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org

Reply via email to