You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Russ Leong <ru...@kikuze.com> on 2001/12/04 03:31:50 UTC

Problem generating PDF

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




Re: Problem generating PDF

Posted by Russ Leong <ru...@kikuze.com>.
Hi Thierry,
    I have placed the fop.jar in the build directory into the execution
classpath but the same error comes up. But do you mean that the code that I
am testing with is correct and it should work?

Russ


----- Original Message -----
From: "Thierry Kormann" <tk...@ilog.fr>
To: "Batik Users" <ba...@xml.apache.org>; "Russ Leong"
<ru...@kikuze.com>
Sent: Thursday, December 06, 2001 6:35 PM
Subject: Re: Problem generating PDF


> On Tuesday 04 December 2001 03:31, Russ Leong wrote:
> > 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)
>
> fop is required to transcode SVG to PDF. Please, ensure that fop jar files
> are in your classpath.
>
> Thierry.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: Problem generating PDF

Posted by Thierry Kormann <tk...@ilog.fr>.
On Tuesday 04 December 2001 03:31, Russ Leong wrote:
> 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)

fop is required to transcode SVG to PDF. Please, ensure that fop jar files 
are in your classpath.

Thierry.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org