You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by AlexandreKouznetsov <al...@knowledgent.com> on 2015/01/30 16:20:56 UTC
converting svg into png with batik, problems with
com/sun/image/codec/jpeg
I got problem converting svg file into png file.
I am using batik as described at
http://thinktibits.blogspot.ca/2012/12/Batik-Convert-SVG-PNG-Java-Program-Example.html
All things are OK as I am running my code from my NetBeens on Windows.
As I moved my jar with dependencies on on Linux server and run my jar from
the command line there , I got problems due to batik seems to refer somehow
the deprecated com/sun/image/codec/jpeg
Namely, I got
Exception in thread "main" java.lang.NoClassDefFoundError:
com/sun/image/codec/jpeg/TruncatedFileException
on my line
// Step-4: Convert and Write output
my_converter.transcode(input_svg_image, output_png_image);
Some people posted for similar problem to add the following attribute for
compilation:
<compilerArgument>-XDignore.symbol.file</compilerArgument>
I tried but it did not not help.
Any suggestions?
Just in case, here is my code:
private void svg2png (String inputSvgfilePath) throws IOException{
try {
//Step -1: We read the input SVG document into Transcoder Input
//We use Java NIO for this purpose
String svg_URI_input =
Paths.get(inputSvgfilePath).toUri().toURL().toString();
TranscoderInput input_svg_image =
new TranscoderInput(svg_URI_input);
//Step-2: Define OutputStream to PNG Image and attach to
TranscoderOutput
String fileNameWithOutExt =
FilenameUtils.removeExtension(inputSvgfilePath);
String outputFilePath=fileNameWithOutExt+".png";
OutputStream png_ostream =
new FileOutputStream(outputFilePath);
TranscoderOutput output_png_image =
new TranscoderOutput(png_ostream);
// Step-3: Create PNGTranscoder and define hints if required
PNGTranscoder my_converter =
new PNGTranscoder();
// Step-4: Convert and Write output
my_converter.transcode(input_svg_image, output_png_image);
// Step 5- close / flush Output Stream
png_ostream.flush();
png_ostream.close();
} catch (MalformedURLException ex) {
Logger.getLogger(PPTXPreprocessor.class.getName()).log(Level.SEVERE, null,
ex);
} catch (FileNotFoundException ex) {
Logger.getLogger(PPTXPreprocessor.class.getName()).log(Level.SEVERE, null,
ex);
} catch (TranscoderException ex) {
Logger.getLogger(PPTXPreprocessor.class.getName()).log(Level.SEVERE, null,
ex);
}
}
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/converting-svg-into-png-with-batik-problems-with-com-sun-image-codec-jpeg-tp5717785.html
Sent from the POI - Dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org