I'm using Apache FOP/Batik to convert SVG to PDF. When running following code java command line program, everything works perfectly:
public byte[] convert(String svg) throws TranscoderException, java.io.IOException {
ByteArrayInputStream instream = new ByteArrayInputStream(svg.getBytes(StandardCharsets.UTF_8));
ByteArrayOutputStream outstream = new ByteArrayOutputStream(50 * 1024);
TranscoderInput input = new TranscoderInput(instream);
TranscoderOutput output = new TranscoderOutput(outstream);
Transcoder transcoder = new PDFTranscoder();
transcoder.transcode(input, output);
return outstream.toByteArray();
}
However, same code called from ruby application running on JRuby (1.7) renders every text character gets wrapped in a grey box. Both jruby and plain java program run on the same machine and use same jvm (Oracle 8, only jvm installed). I verified it's not an input/output issue altering the method to read the svg from a file and writing resulting PDF back.
Any ideas what could cause this behavior?
Characters with jruby
Apache FOP adds these boxes when the log4j.logger.org.apache.fop logger is set to DEBUG, presumably for some kind of diagnostic purpose. Switch off this logger to remove the borders.
I found the answer from reading this on the Batik forum: https://mail-archives.apache.org/mod_mbox/xmlgraphics-batik-users/201601.mbox/browser
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With