Package org.apache.batik.transcoder

Examples of org.apache.batik.transcoder.Transcoder


        else{
            dstFiles = computeDstFiles(sources);
        }

        // Now, get the transcoder to use for the operation
        Transcoder transcoder = destinationType.getTranscoder();
        if(transcoder == null) {
            throw new SVGConverterException(ERROR_CANNOT_ACCESS_TRANSCODER,
                                             new Object[]{destinationType.toString()},
                                             true /* fatal error */);
        }

        // Now, compute the set of transcoding hints to use
        Map hints = computeTranscodingHints();
        transcoder.setTranscodingHints(hints);

        // Notify listener that task has been computed
        if(!controller.proceedWithComputedTask(transcoder,
                                               hints,
                                               sources,
View Full Code Here


        else{
            dstFiles = computeDstFiles(sources);
        }

        // Now, get the transcoder to use for the operation
        Transcoder transcoder = destinationType.getTranscoder();
        if(transcoder == null) {
            throw new SVGConverterException(ERROR_CANNOT_ACCESS_TRANSCODER,
                                             new Object[]{destinationType.toString()},
                                             true /* fatal error */);
        }

        // Now, compute the set of transcoding hints to use
        Map hints = computeTranscodingHints();
        transcoder.setTranscodingHints(hints);

        // Notify listener that task has been computed
        if(!controller.proceedWithComputedTask(transcoder,
                                               hints,
                                               sources,
View Full Code Here

     * @throws TranscoderException In case of a transcoding problem
     */
    public void convertSVG2PDF(File svg, File pdf) throws IOException, TranscoderException {
       
        //Create transcoder
        Transcoder transcoder = new PDFTranscoder();
        //Transcoder transcoder = new org.apache.fop.render.ps.PSTranscoder();
       
        //Setup input
        InputStream in = new java.io.FileInputStream(svg);
        try {
            TranscoderInput input = new TranscoderInput(in);
           
            //Setup output
            OutputStream out = new java.io.FileOutputStream(pdf);
            out = new java.io.BufferedOutputStream(out);
            try {
                TranscoderOutput output = new TranscoderOutput(out);
               
                //Do the transformation
                transcoder.transcode(input, output);
            } finally {
                out.close();
            }
        } finally {
            in.close();
View Full Code Here

     * Without special configuration stuff.
     * @throws Exception if a problem occurs
     */
    public void testGenericPDFTranscoder() throws Exception {
        //Create transcoder
        Transcoder transcoder = createTranscoder();
       
        //Setup input
        File svgFile = new File(getBaseDir(), "test/resources/fop/svg/text.svg");
        InputStream in = new java.io.FileInputStream(svgFile);
        try {
            TranscoderInput input = new TranscoderInput(in);
           
            //Setup output
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            try {
                TranscoderOutput output = new TranscoderOutput(out);
               
                //Do the transformation
                transcoder.transcode(input, output);
            } finally {
                out.close();
            }
            assertTrue("Some output expected", out.size() > 0);
        } finally {
View Full Code Here

     * Without special configuration stuff.
     * @throws Exception if a problem occurs
     */
    public void testGenericPDFTranscoder() throws Exception {
        //Create transcoder
        Transcoder transcoder = createTranscoder();

        //Setup input
        File svgFile = new File(getBaseDir(), "test/resources/fop/svg/text.svg");
        InputStream in = new java.io.FileInputStream(svgFile);
        try {
            TranscoderInput input = new TranscoderInput(in);

            //Setup output
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            try {
                TranscoderOutput output = new TranscoderOutput(out);

                //Do the transformation
                transcoder.transcode(input, output);
            } finally {
                out.close();
            }
            assertTrue("Some output expected", out.size() > 0);
        } finally {
View Full Code Here

     * @throws Exception if a problem occurs
     */
    @Test
    public void testGenericPDFTranscoder() throws Exception {
        //Create transcoder
        Transcoder transcoder = createTranscoder();

        //Setup input
        File svgFile = new File(getBaseDir(), "test/resources/fop/svg/text.svg");
        InputStream in = new java.io.FileInputStream(svgFile);
        try {
            TranscoderInput input = new TranscoderInput(in);

            //Setup output
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            try {
                TranscoderOutput output = new TranscoderOutput(out);

                //Do the transformation
                transcoder.transcode(input, output);
            } finally {
                out.close();
            }
            assertTrue("Some output expected", out.size() > 0);
        } finally {
View Full Code Here

     * Without special configuration stuff.
     * @throws Exception if a problem occurs
     */
    public void testGenericPDFTranscoder() throws Exception {
        //Create transcoder
        Transcoder transcoder = createTranscoder();
       
        //Setup input
        File svgFile = new File(getBaseDir(), "test/resources/fop/svg/text.svg");
        InputStream in = new java.io.FileInputStream(svgFile);
        try {
            TranscoderInput input = new TranscoderInput(in);
           
            //Setup output
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            try {
                TranscoderOutput output = new TranscoderOutput(out);
               
                //Do the transformation
                transcoder.transcode(input, output);
            } finally {
                out.close();
            }
            assertTrue("Some output expected", out.size() > 0);
        } finally {
View Full Code Here

    ServletOutputStream out = response.getOutputStream();
    try {
      if (null != type && null != svg) {
        svg = svg.replaceAll(":rect", "rect");
        String ext = "";
        Transcoder t = null;
        if (type.equals("image/png")) {
          ext = "png";
          t = new PNGTranscoder();
        } else if (type.equals("image/jpeg")) {
          ext = "jpg";
          t = new JPEGTranscoder();
        } else if (type.equals("application/pdf")) {
          ext = "pdf";
          t = (Transcoder) new PDFTranscoder();
        } else if (type.equals("image/svg+xml"))
          ext = "svg";
        response.addHeader("Content-Disposition",
            "attachment; filename=" + new String(filename.getBytes("GBK"),"ISO-8859-1") + "." + ext);
        response.addHeader("Content-Type", type);

        if (null != t) {
          TranscoderInput input = new TranscoderInput(
              new StringReader(svg));
          TranscoderOutput output = new TranscoderOutput(out);

          try {
            t.transcode(input, output);
          } catch (TranscoderException e) {
            out
                .print("Problem transcoding stream. See the web logs for more details.");
            e.printStackTrace();
          }
View Full Code Here

    ServletOutputStream out = response.getOutputStream();
    try {
      if (null != type && null != svg) {
        svg = svg.replaceAll(":rect", "rect");
        String ext = "";
        Transcoder t = null;
        if (type.equals("image/png")) {
          ext = "png";
          t = new PNGTranscoder();
        } else if (type.equals("image/jpeg")) {
          ext = "jpg";
          t = new JPEGTranscoder();
        } else if (type.equals("application/pdf")) {
          ext = "pdf";
          t = (Transcoder) new PDFTranscoder();
        } else if (type.equals("image/svg+xml"))
          ext = "svg";
        response.addHeader("Content-Disposition",
            "attachment; filename=" + new String(filename.getBytes("GBK"),"ISO-8859-1") + "." + ext);
        response.addHeader("Content-Type", type);

        if (null != t) {
          TranscoderInput input = new TranscoderInput(
              new StringReader(svg));
          TranscoderOutput output = new TranscoderOutput(out);

          try {
            t.transcode(input, output);
          } catch (TranscoderException e) {
            out.print("Problem transcoding stream. See the web logs for more details.");
            e.printStackTrace();
          }
        } else if (ext.equals("svg")) {
View Full Code Here

     * @throws TranscoderException In case of a transcoding problem
     */
    public void convertSVG2PDF(File svg, File pdf) throws IOException, TranscoderException {
       
        //Create transcoder
        Transcoder transcoder = new PDFTranscoder();
        //Transcoder transcoder = new org.apache.fop.render.ps.PSTranscoder();
       
        //Setup input
        InputStream in = new java.io.FileInputStream(svg);
        try {
            TranscoderInput input = new TranscoderInput(in);
           
            //Setup output
            OutputStream out = new java.io.FileOutputStream(pdf);
            out = new java.io.BufferedOutputStream(out);
            try {
                TranscoderOutput output = new TranscoderOutput(out);
               
                //Do the transformation
                transcoder.transcode(input, output);
            } finally {
                out.close();
            }
        } finally {
            in.close();
View Full Code Here

TOP

Related Classes of org.apache.batik.transcoder.Transcoder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.