Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Border-boxed characters when using Batik/FOP SVG to PDF conversion under JRuby

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

like image 826
Urmo R Avatar asked Jan 01 '26 02:01

Urmo R


1 Answers

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

like image 195
Matt Farrow Avatar answered Jan 02 '26 15:01

Matt Farrow