I am trying to do something similar as described below but using the PDFTranscoder. I modified the code as follows:

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.fop.svg.PDFTranscoder;
import org.apache.batik.transcoder.TranscoderException;
import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.TranscoderOutput;

public class TranscodingServlet extends HttpServlet {

   public void doPost(HttpServletRequest request,
                     HttpServletResponse response)
       throws IOException, ServletException {

       response.setContentType("application/pdf");

       PDFTranscoder t = new PDFTranscoder();
/*t.addTranscodingHint(ImageTranscoder.KEY_WIDTH, new Float(1056));*/ /*t.addTranscodingHint(ImageTranscoder.KEY_HEIGHT, new Float(816));*/
       TranscoderInput input = new TranscoderInput(request);
TranscoderOutput output = new TranscoderOutput(response.getOutputStream());
       try {
           t.transcode(input, output);
       } catch (TranscoderException ex) {
           throw new ServletException(ex);
       }
   }
}

I am trying to compile this with:

javac -classpath servlet-api.jar;batik-transcoder.jar;pdf-transcoder.jar TranscodingServlet.java

The three .jar files are in the same directory as TranscodingServlet.java. servlet-api.jar is from Apache-tomcat 6.0 and the others are from Batik 1.7. I think my JAVA is setup OK - I can compile all of Batik from source. The error I get is:

TranscodingServlet.java:24 cannot find symbol
symbol : construction TranscoderInput(javax.servlet.htto.HttpServletRequest)
location : class org.apache.batik.transcoder.TranscoderInput
   TranscoderInput input = new TranscoderInput(request);

The error ^ points to new in the last line. Can anyone help on this? I am afraid I am lost when it comes to JAVA.

Thanks
Bruce Rindahl


Cameron McCormack wrote:
horstpeter:
OK, I know a lot of people had the same problem, but reading through forums
for 2 days now didn't help me at all.
I have a basic website with a svg embedded. The SVG has some JS in there for the user to change the svg. I would love to have a button to export the svg to a JPEG. I already downloaded the batik package and put it on the server, I just
can't find the right way to call the rasterizer.

If you can run Java servlets on your server, then you can write a simple
servlet that will do the rasterising.  Here is a simple example:

 http://mcc.id.au/2007/09/batik-course/code/transcoding-servlet/

The actual code is in WEB-INF/classes/TranscodingServlet.java.  That
example servlet causes a URI with the following form to return a PNG:

 http://server/transcoding-servlet/transcode?uri=<uri-of-SVG-document>
   &width=<width-of-output-PNG>&height=<height-of-output-PNG>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to