congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Transcoder.transcode
Code IndexAdd Tabnine to your IDE (free)

How to use
transcode
method
in
org.apache.batik.transcoder.Transcoder

Best Java code snippets using org.apache.batik.transcoder.Transcoder.transcode (Showing top 20 results out of 315)

origin: stackoverflow.com

 import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

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

public class Test {
  public static void main(String[] argv) throws TranscoderException, FileNotFoundException {
    Transcoder transcoder = new PDFTranscoder();
    TranscoderInput transcoderInput = new TranscoderInput(new FileInputStream(new File("/tmp/test.svg")));
    TranscoderOutput transcoderOutput = new TranscoderOutput(new FileOutputStream(new File("/tmp/test.pdf")));
    transcoder.transcode(transcoderInput, transcoderOutput);
  }
}
origin: elki-project/elki

/**
 * Transcode a document into a file using the given transcoder.
 *
 * @param file Output file
 * @param transcoder Transcoder to use
 * @throws IOException On write errors
 * @throws TranscoderException On input/parsing errors
 */
protected void transcode(File file, Transcoder transcoder) throws IOException, TranscoderException {
 // Disable validation, performance is more important here (thumbnails!)
 transcoder.addTranscodingHint(XMLAbstractTranscoder.KEY_XML_PARSER_VALIDATING, Boolean.FALSE);
 SVGDocument doc = cloneDocument();
 TranscoderInput input = new TranscoderInput(doc);
 OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
 TranscoderOutput output = new TranscoderOutput(out);
 transcoder.transcode(input, output);
 out.flush();
 out.close();
}
origin: com.arsframework/ars-core

/**
 * 将SVG输入流转换并写入到JPEG输出流
 *
 * @param reader SVG字符流
 * @param output JPEG输出流
 * @throws TranscoderException 转换异常
 */
public static void svg2jpeg(Reader reader, OutputStream output) throws TranscoderException {
  if (reader == null) {
    throw new IllegalArgumentException("Reader must not be null");
  }
  if (output == null) {
    throw new IllegalArgumentException("OutputStream must not be null");
  }
  Transcoder transcoder = new JPEGTranscoder();
  transcoder.transcode(new TranscoderInput(reader), new TranscoderOutput(output));
}
origin: com.arsframework/ars-core

/**
 * 将SVG输入流转换并写入到JPEG输出流
 *
 * @param input  SVG输入流
 * @param output JPEG输出流
 * @throws TranscoderException 转换异常
 */
public static void svg2jpeg(InputStream input, OutputStream output) throws TranscoderException {
  if (input == null) {
    throw new IllegalArgumentException("InputStream must not be null");
  }
  if (output == null) {
    throw new IllegalArgumentException("OutputStream must not be null");
  }
  Transcoder transcoder = new JPEGTranscoder();
  transcoder.transcode(new TranscoderInput(input), new TranscoderOutput(output));
}
origin: com.arsframework/ars-core

/**
 * 将SVG输入流转换并写入到PNG输出流
 *
 * @param input  SVG输入流
 * @param output PNG输出流
 * @throws TranscoderException 转换异常
 */
public static void svg2png(InputStream input, OutputStream output) throws TranscoderException {
  if (input == null) {
    throw new IllegalArgumentException("InputStream must not be null");
  }
  if (output == null) {
    throw new IllegalArgumentException("OutputStream must not be null");
  }
  Transcoder transcoder = new PNGTranscoder();
  transcoder.transcode(new TranscoderInput(input), new TranscoderOutput(output));
}
origin: de.lmu.ifi.dbs.elki/elki-batik-visualization

/**
 * Transcode a document into a file using the given transcoder.
 *
 * @param file Output file
 * @param transcoder Transcoder to use
 * @throws IOException On write errors
 * @throws TranscoderException On input/parsing errors
 */
protected void transcode(File file, Transcoder transcoder) throws IOException, TranscoderException {
 // Disable validation, performance is more important here (thumbnails!)
 transcoder.addTranscodingHint(XMLAbstractTranscoder.KEY_XML_PARSER_VALIDATING, Boolean.FALSE);
 SVGDocument doc = cloneDocument();
 TranscoderInput input = new TranscoderInput(doc);
 OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
 TranscoderOutput output = new TranscoderOutput(out);
 transcoder.transcode(input, output);
 out.flush();
 out.close();
}
origin: com.arsframework/ars-core

/**
 * 将SVG输入流转换并写入到PNG输出流
 *
 * @param reader SVG字符流
 * @param output PNG输出流
 * @throws TranscoderException 转换异常
 */
public static void svg2png(Reader reader, OutputStream output) throws TranscoderException {
  if (reader == null) {
    throw new IllegalArgumentException("Reader must not be null");
  }
  if (output == null) {
    throw new IllegalArgumentException("OutputStream must not be null");
  }
  Transcoder transcoder = new PNGTranscoder();
  transcoder.transcode(new TranscoderInput(reader), new TranscoderOutput(output));
}
origin: com.arsframework/ars-core

/**
 * 将SVG输入流转换并写入到PDF输出流
 *
 * @param reader SVG字符流
 * @param output PDF输出流
 * @throws TranscoderException 转换异常
 */
public static void svg2pdf(Reader reader, OutputStream output) throws TranscoderException {
  if (reader == null) {
    throw new IllegalArgumentException("Reader must not be null");
  }
  if (output == null) {
    throw new IllegalArgumentException("OutputStream must not be null");
  }
  Transcoder transcoder = new PDFTranscoder();
  transcoder.transcode(new TranscoderInput(reader), new TranscoderOutput(output));
}
origin: com.arsframework/ars-core

/**
 * 将SVG输入流转换并写入到PDF输出流
 *
 * @param input  SVG输入流
 * @param output PDF输出流
 * @throws TranscoderException 转换异常
 */
public static void svg2pdf(InputStream input, OutputStream output) throws TranscoderException {
  if (input == null) {
    throw new IllegalArgumentException("InputStream must not be null");
  }
  if (output == null) {
    throw new IllegalArgumentException("OutputStream must not be null");
  }
  Transcoder transcoder = new PDFTranscoder();
  transcoder.transcode(new TranscoderInput(input), new TranscoderOutput(output));
}
origin: fr.avianey.apache-xmlgraphics/batik

/**
 * Runs the pretty printer.
 */
public void run() {
  if (arguments.length == 0) {
    printUsage();
    return;
  }
  try {
    for (;;) {
      OptionHandler oh = (OptionHandler)handlers.get(arguments[index]);
      if (oh == null) {
        break;
      }
      oh.handleOption();
    }
    TranscoderInput in;
    in = new TranscoderInput(new java.io.FileReader(arguments[index++]));
    TranscoderOutput out;
    if (index < arguments.length) {
      out = new TranscoderOutput(new java.io.FileWriter(arguments[index]));
    } else {
      out = new TranscoderOutput(new java.io.OutputStreamWriter(System.out));
    }
    transcoder.transcode(in, out);
  } catch (Exception e) {
    e.printStackTrace();
    printUsage();
  }
}
origin: org.openimaj/vector-image

  /**
   * Write an SVG image to a file with the given transcoder to determine the
   * format
   * 
   * @param image
   *            the image
   * @param output
   *            the file to write to
   * @param trans
   *            the transcoder
   * @throws IOException
   *             if an error occurs during writing
   * @throws TranscoderException
   *             if an error occurs during transcoding
   */
  public static void write(final SVGImage image, final File output, Transcoder trans) throws IOException,
      TranscoderException
  {
    final TranscoderInput input = new TranscoderInput(image.createRenderer().getDocument());
    final TranscoderOutput toutput = new TranscoderOutput(new FileOutputStream(output));

    trans.transcode(input, toutput);
  }
}
origin: apache/batik

/**
 * Runs the pretty printer.
 */
public void run() {
  if (arguments.length == 0) {
    printUsage();
    return;
  }
  try {
    for (;;) {
      OptionHandler oh = (OptionHandler)handlers.get(arguments[index]);
      if (oh == null) {
        break;
      }
      oh.handleOption();
    }
    TranscoderInput in;
    in = new TranscoderInput(new java.io.FileReader(arguments[index++]));
    TranscoderOutput out;
    if (index < arguments.length) {
      out = new TranscoderOutput(new java.io.FileWriter(arguments[index]));
    } else {
      out = new TranscoderOutput(new java.io.OutputStreamWriter(System.out));
    }
    transcoder.transcode(in, out);
  } catch (Exception e) {
    e.printStackTrace();
    printUsage();
  }
}
origin: stackoverflow.com

 public class SvgToPdfConverter {

  private ArrayList<byte[]> pdfs = new ArrayList<byte[]>();

  public void convertSVG2PDF(File svg) throws IOException, TranscoderException {
    // Create transcoder
    Transcoder transcoder = new PDFTranscoder();
    // Input
    FileInputStream bais = new FileInputStream(svg);
    // Output
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    TranscoderInput input = new TranscoderInput(bais);
    TranscoderOutput output = new TranscoderOutput(baos);
    // Do the transformation
    transcoder.transcode(input, output);
    pdfs.add(baos.toByteArray());
  }

  public void merge(File mergedPDF) throws IOException, COSVisitorException {
    PDFMergerUtility ut = new PDFMergerUtility();
    for (byte[] bytes : pdfs) {
      ut.addSource(new ByteArrayInputStream(bytes));
    }
    ut.setDestinationStream(new FileOutputStream(mergedPDF));
    ut.mergeDocuments();
  }
}
origin: openimaj/openimaj

  /**
   * Write an SVG image to a file with the given transcoder to determine the
   * format
   * 
   * @param image
   *            the image
   * @param output
   *            the file to write to
   * @param trans
   *            the transcoder
   * @throws IOException
   *             if an error occurs during writing
   * @throws TranscoderException
   *             if an error occurs during transcoding
   */
  public static void write(final SVGImage image, final File output, Transcoder trans) throws IOException,
      TranscoderException
  {
    final TranscoderInput input = new TranscoderInput(image.createRenderer().getDocument());
    final TranscoderOutput toutput = new TranscoderOutput(new FileOutputStream(output));

    trans.transcode(input, toutput);
  }
}
origin: org.apache.cocoon/cocoon-batik-impl

/**
 * Receive notification of a successfully completed DOM tree generation.
 */
public void notify(Document doc) throws SAXException {
  
  try {
    TranscoderInput transInput = new TranscoderInput(doc);
    // Buffering is done by the pipeline (See shouldSetContentLength)
    TranscoderOutput transOutput = new TranscoderOutput(this.output);
    transcoder.transcode(transInput, transOutput);
  } catch (TranscoderException ex) {
    if (ex.getException() != null) {
      if (getLogger().isDebugEnabled()) {
        getLogger().debug("Got transcoder exception writing image, rethrowing nested exception", ex);
      }
      throw new SAXException("Exception writing image", ex.getException());
    }
    if (getLogger().isDebugEnabled()) {
      getLogger().debug("Got transcoder exception writing image, rethrowing", ex);
    }
    throw new SAXException("Exception writing image", ex);
  } catch (Exception ex) {
    if (getLogger().isDebugEnabled()) {
      getLogger().debug("Got exception writing image, rethrowing", ex);
    }
    throw new SAXException("Exception writing image", ex);
  }
}
origin: net.sourceforge.ondex.apps/ovtk2

/**
 * Transcodes the image using the transcoder specified
 * 
 * @param t
 * @param svgGenerator
 * @param useCSS
 * @param rect
 * @param fos
 * @throws IOException
 * @throws TranscoderException
 */
public static void transcode(Transcoder t, SVGGraphics2D svgGenerator, boolean useCSS, Rectangle rect, FileOutputStream fos) throws IOException, TranscoderException {
  PipedWriter pout = new PipedWriter();
  BufferedReader rin = new BufferedReader(new PipedReader(pout));
  new Piper(svgGenerator, useCSS, pout).start();
  t.addTranscodingHint(JPEGTranscoder.KEY_HEIGHT, Float.valueOf(rect.height));
  t.addTranscodingHint(JPEGTranscoder.KEY_WIDTH, Float.valueOf(rect.width));
  t.transcode(new TranscoderInput(rin), new TranscoderOutput(fos));
}
origin: stackoverflow.com

transcoder.transcode(transcoderInput, transcoderOutput);
origin: fr.avianey.apache-xmlgraphics/batik

  transcoder.transcode(input, output);
  success = true;
} catch(Exception te) {
origin: apache/batik

  transcoder.transcode(input, output);
  success = true;
} catch(Exception te) {
origin: org.apache.xmlgraphics/batik-svgrasterizer

  transcoder.transcode(input, output);
  success = true;
} catch(Exception te) {
org.apache.batik.transcoderTranscodertranscode

Javadoc

Transcodes the specified input in the specified output.

Popular methods of Transcoder

  • addTranscodingHint
    Sets the value of a single preference for the transcoding process.
  • setTranscodingHints
    Sets the values of all preferences for the transcoding algorithms with the specified hints.

Popular in Java

  • Start an intent from android
  • startActivity (Activity)
  • getSharedPreferences (Context)
  • findViewById (Activity)
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • Socket (java.net)
    Provides a client-side TCP socket.
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now