Hi all,
 
As I read the ability to output to JPEG or PDF is because of the transcoders, I changed the transcoder from JPEG to PDF to find out if it is so.

import java.io.*;
import org.apache.batik.transcoder.image.JPEGTranscoder;
import org.apache.fop.svg.PDFTranscoder;
import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.TranscoderOutput;

public class SaveAsJpeg {
    public static void main(String [] args) throws Exception {
        // create a JPEG transcoder
        //JPEGTranscoder t = new JPEGTranscoder();
        PDFTranscoder t = new PDFTranscoder();
        // set the transcoding hints
        //t.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(.8));
        // create the transcoder input
        String svgURI = new File("G://batik//test.svg").toURL().toString();
        TranscoderInput input = new TranscoderInput(svgURI);
        // create the transcoder output
        OutputStream ostream = new FileOutputStream("G://batik//test.pdf");
        TranscoderOutput output = new TranscoderOutput(ostream);
        // save the image
        t.transcode(input, output);
        // flush and close the stream then exit
        ostream.flush();
        ostream.close();
        System.exit(0);
    }
}
 
Compilation was fine but when I ran the code, I got the follow exception
 
java.lang.AbstractMethodError
        at org.apache.batik.bridge.DocumentLoader.<init>(Unknown Source)
        at org.apache.batik.bridge.BridgeContext.<init>(Unknown Source)
        at org.apache.fop.svg.PDFTranscoder.transcode(PDFTranscoder.java:180)
        at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown Source)
        at kikuze.printmanager.batik.SaveAsJpeg.main(SaveAsJpeg.java:25)
 
Can anyone tell me what went wrong? Thanks.
 
Russ

 

Reply via email to