Package org.apache.batik.transcoder

Examples of org.apache.batik.transcoder.SVGAbstractTranscoder


    TranscoderInput input = new TranscoderInput(new StringReader(svg));
    // Create the transcoder output
    TranscoderOutput transOutput = new TranscoderOutput(stream);
    // get right Transcoder, depends on mime
    SVGAbstractTranscoder transcoder = SVGRasterizer.getTranscoder(mime);
    if (width != null) {
      /*
       * If the raster image height is not provided (using the
       * KEY_HEIGHT), the transcoder will compute the raster image height
       * by keeping the aspect ratio of the SVG document.
       */
      transcoder.addTranscodingHint(SVGAbstractTranscoder.KEY_WIDTH,
          width);
    }
    transcoder.transcode(input, transOutput);

    return stream;

  }
View Full Code Here


  }

  public static SVGAbstractTranscoder getTranscoder(MimeType mime)
      throws SVGRasterizerException {

    SVGAbstractTranscoder transcoder = null;

    switch (mime) {
    case PNG:
      transcoder = new PNGTranscoder();
      break;
    case JPEG:
      transcoder = new JPEGTranscoder();
      transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY,
          new Float(0.9));
      break;
    case PDF:
      transcoder = new PDFTranscoder();
      break;
View Full Code Here

      TranscoderException {

    TranscoderInput input = new TranscoderInput(new StringReader(svg));
    TranscoderOutput transOutput = new TranscoderOutput(stream);
    // get right Transcoder, this depends on the mime
    SVGAbstractTranscoder transcoder = SVGRasterizer.getTranscoder(mime);

    if (width != null) {
      /*
       * If the raster image height is not provided (using the
       * KEY_HEIGHT), the transcoder will compute the raster image height
       * by keeping the aspect ratio of the SVG document.
       */
      transcoder.addTranscodingHint(SVGAbstractTranscoder.KEY_WIDTH,
          width);
    }

    if (width == null && scale != null && scale != 0.00) {
      Float svgWidth = getWidthFromSvg(svg);
      // calculate width from svg
      if (svgWidth != null) {
        transcoder.addTranscodingHint(SVGAbstractTranscoder.KEY_WIDTH,
            svgWidth * scale);
      }
    }

    transcoder.transcode(input, transOutput);

    return stream;
  }
View Full Code Here

  }

  public static SVGAbstractTranscoder getTranscoder(MimeType mime)
      throws SVGRasterizerException {

    SVGAbstractTranscoder transcoder = null;

    switch (mime) {
    case PNG:
      transcoder = new PNGTranscoder();
      break;
    case JPEG:
      transcoder = new JPEGTranscoder();
      transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY,
          new Float(0.9));
      break;
    case PDF:
      transcoder = new PDFTranscoder();
      break;
View Full Code Here

TOP

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

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.