Codota Logo
TranscoderOutput.<init>
Code IndexAdd Codota to your IDE (free)

How to use
org.apache.batik.transcoder.TranscoderOutput
constructor

Best Java code snippets using org.apache.batik.transcoder.TranscoderOutput.<init> (Showing top 20 results out of 351)

  • Common ways to obtain TranscoderOutput
private void myMethod () {
TranscoderOutput t =
  • Codota IconOutputStream ostream;new TranscoderOutput(ostream)
  • Codota IconFile file;new TranscoderOutput(new FileOutputStream(file))
  • Smart code suggestions by Codota
}
origin: hs-web/hsweb-framework

@PutMapping(value = "/{modelId}")
@ResponseStatus(value = HttpStatus.OK)
@Authorize(action = Permission.ACTION_UPDATE)
public void saveModel(@PathVariable String modelId,
           @RequestParam Map<String, String> values) throws TranscoderException, IOException {
  Model model = repositoryService.getModel(modelId);
  JSONObject modelJson = JSON.parseObject(model.getMetaInfo());
  modelJson.put(MODEL_NAME, values.get("name"));
  modelJson.put(MODEL_DESCRIPTION, values.get("description"));
  model.setMetaInfo(modelJson.toString());
  model.setName(values.get("name"));
  repositoryService.saveModel(model);
  repositoryService.addModelEditorSource(model.getId(), values.get("json_xml").getBytes("utf-8"));
  InputStream svgStream = new ByteArrayInputStream(values.get("svg_xml").getBytes("utf-8"));
  TranscoderInput input = new TranscoderInput(svgStream);
  PNGTranscoder transcoder = new PNGTranscoder();
  // Setup output
  ByteArrayOutputStream outStream = new ByteArrayOutputStream();
  TranscoderOutput output = new TranscoderOutput(outStream);
  // Do the transformation
  transcoder.transcode(input, output);
  final byte[] result = outStream.toByteArray();
  repositoryService.addModelEditorSourceExtra(model.getId(), result);
  outStream.close();
}
origin: jooby-project/jooby

transcoder.addTranscodingHint(PNGTranscoder.KEY_WIDTH, w);
transcoder.addTranscodingHint(PNGTranscoder.KEY_HEIGHT, h);
transcoder.transcode(new TranscoderInput(in), new TranscoderOutput(out));
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: haraldk/TwelveMonkeys

private synchronized void init() throws IOException {
  // Need the extra test, to avoid throwing an IOException from the Transcoder
  if (imageInput == null) {
    throw new IllegalStateException("input == null");
  }
  if (reader == null) {
    WMFTranscoder transcoder = new WMFTranscoder();
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    Writer writer = new OutputStreamWriter(output, "UTF8");
    try {
      TranscoderInput in = new TranscoderInput(IIOUtil.createStreamAdapter(imageInput));
      TranscoderOutput out = new TranscoderOutput(writer);
      // TODO: Transcodinghints?
      transcoder.transcode(in, out);
    }
    catch (TranscoderException e) {
      throw new IIOException(e.getMessage(), e);
    }
    reader = new SVGImageReader(getOriginatingProvider());
    reader.setInput(ImageIO.createImageInputStream(new ByteArrayInputStream(output.toByteArray())));
  }
}
origin: bill1012/AdminEAP

TranscoderOutput output = new TranscoderOutput(outStream);
origin: org.phenotips/xwiki-platform-svg

private void rasterizeToFile(String content, File out, int width, int height) throws IOException
{
  if (out.exists()) {
    this.logger.debug("Reusing existing temporary raster image: {}", out.getAbsolutePath());
    return;
  }
  try (OutputStream fout = new FileOutputStream(out)) {
    this.logger.debug("Rasterizing to temp file: {}", out.getAbsolutePath());
    TranscoderInput input = new TranscoderInput(new StringReader(content));
    TranscoderOutput output = new TranscoderOutput(fout);
    rasterize(input, output, width, height);
  }
}
origin: phenotips/phenotips

private void rasterizeToFile(String content, File out, int width, int height) throws IOException
{
  if (out.exists()) {
    this.logger.debug("Reusing existing temporary raster image: {}", out.getAbsolutePath());
    return;
  }
  try (OutputStream fout = new FileOutputStream(out)) {
    this.logger.debug("Rasterizing to temp file: {}", out.getAbsolutePath());
    TranscoderInput input = new TranscoderInput(new StringReader(content));
    TranscoderOutput output = new TranscoderOutput(fout);
    rasterize(input, output, width, height);
  }
}
origin: liuyueyi/quick-media

private static ByteArrayOutputStream saveAsBytes(ImageTranscoder t, Document doc) throws Exception {
  TranscoderInput input = new TranscoderInput(doc);
  ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
  TranscoderOutput output = new TranscoderOutput(outputStream);
  t.transcode(input, output);
  outputStream.flush();
  return outputStream;
}
origin: apache/batik

  public void run() {
    try {
      currentSavePath = f;
      OutputStream ostream =
        new BufferedOutputStream(new FileOutputStream(f));
      trans.writeImage(img, new TranscoderOutput(ostream));
      ostream.close();
    } catch (Exception ex) { }
    statusBar.setMessage
      (resources.getString("Message.done"));
  }
}.start();
origin: fr.avianey.apache-xmlgraphics/batik

  public void run() {
    try {
      currentSavePath = f;
      OutputStream ostream =
        new BufferedOutputStream(new FileOutputStream(f));
      trans.writeImage(img, new TranscoderOutput(ostream));
      ostream.close();
    } catch (Exception ex) { }
    statusBar.setMessage
      (resources.getString("Message.done"));
  }
}.start();
origin: org.tinywind/scheme-reporter

private byte[] pngBytesFromSvg(String svg) throws TranscoderException {
  final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
  final TranscoderInput input = new TranscoderInput(new StringReader(svg));
  final TranscoderOutput output = new TranscoderOutput(outputStream);
  final PNGTranscoder converter = new PNGTranscoder();
  converter.transcode(input, output);
  byte[] bytes = outputStream.toByteArray();
  try {
    outputStream.close();
  } catch (IOException e) {
    e.printStackTrace();
  }
  return bytes;
}
origin: apache/batik

/**
 * Helper method: creates a valid reference image
 */
public static URL createValidReferenceImage(String svgContent) throws Exception{
  TranscoderInput validSrc = new TranscoderInput(new StringReader(svgContent));
  
  File tmpFile = File.createTempFile(SVGRenderingAccuracyTest.TEMP_FILE_PREFIX,
                    SVGRenderingAccuracyTest.TEMP_FILE_SUFFIX);
  
  TranscoderOutput validDst 
    = new TranscoderOutput(new FileOutputStream(tmpFile));
  
  ImageTranscoder transcoder 
    = new PNGTranscoder();
  
  transcoder.transcode(validSrc, validDst);
  
  tmpFile.deleteOnExit();
  
  return tmpFile.toURI().toURL();
}
origin: fr.avianey.apache-xmlgraphics/batik

  public void run() {
    try {
      currentSavePath = f;
      OutputStream ostream = new BufferedOutputStream
        (new FileOutputStream(f));
      trans.writeImage
        (img, new TranscoderOutput(ostream));
      ostream.close();
    } catch (Exception ex) {}
    statusBar.setMessage
      (resources.getString("Message.done"));
  }
}.start();
origin: fr.avianey.apache-xmlgraphics/batik

  public void run() {
    try {
      currentSavePath = f;
      OutputStream ostream =
        new BufferedOutputStream(new FileOutputStream(f));
      trans.writeImage(img,
               new TranscoderOutput(ostream));
      ostream.close();
    } catch (Exception ex) {}
    statusBar.setMessage
      (resources.getString("Message.done"));
  }
}.start();
origin: com.github.mkolisnyk/cucumber-report-generator

private void convertSvgToPng(File svg, File png) throws Exception {
  String svgUriInput = svg.toURI().toURL().toString();
  TranscoderInput inputSvgImage = new TranscoderInput(svgUriInput);
  //Step-2: Define OutputStream to PNG Image and attach to TranscoderOutput
  OutputStream pngOStream = new FileOutputStream(png);
  TranscoderOutput outputPngImage = new TranscoderOutput(pngOStream);
  // Step-3: Create PNGTranscoder and define hints if required
  PNGTranscoder myConverter = new PNGTranscoder();
  // Step-4: Convert and Write output
  myConverter.transcode(inputSvgImage, outputPngImage);
  // Step 5- close / flush Output Stream
  pngOStream.flush();
  pngOStream.close();
}
public String replaceSvgWithPng(File htmlFile) throws Exception {
origin: apache/batik

  public void run() {
    try {
      currentSavePath = f;
      OutputStream ostream = new BufferedOutputStream
        (new FileOutputStream(f));
      trans.writeImage
        (img, new TranscoderOutput(ostream));
      ostream.close();
    } catch (Exception ex) {}
    statusBar.setMessage
      (resources.getString("Message.done"));
  }
}.start();
origin: apache/batik

  public void run() {
    try {
      currentSavePath = f;
      OutputStream ostream =
        new BufferedOutputStream(new FileOutputStream(f));
      trans.writeImage(img,
               new TranscoderOutput(ostream));
      ostream.close();
    } catch (Exception ex) {}
    statusBar.setMessage
      (resources.getString("Message.done"));
  }
}.start();
origin: com.atlassian.jira/jira-core

private void transcodeAndTag(final Avatar avatar, final Avatar.Size size, final File transcoded) throws IOException
{
  try (final OutputStream outputStream = new FileOutputStream(transcoded);
     final InputStream svgFileStream = AvatarManagerImpl.class.getResourceAsStream("/avatars/" + avatar.getFileName()))
  {
    final TranscoderInput transcoderInput = new TranscoderInput(svgFileStream);
    final TranscoderOutput transcoderOutput = new TranscoderOutput(outputStream);
    final PNGTranscoder transcoder = newPNGTranscoder(size);
    transcoder.transcode(transcoderInput, transcoderOutput);
    avatarTagger.tagSingleAvatarFile(transcoded, transcoded);
  }
  catch (TranscoderException e)
  {
    throw new RuntimeException(e);
  }
}
origin: omero/server

/**
 * Returns the image that represents the SVG document as a JPEG.
 *
 * @param outputStream The stream to use.
 */
public void createJPEG(OutputStream outputStream)
  throws TranscoderException {
  // Create a JPEG transcoder
  JPEGTranscoder t = new JPEGTranscoder();
  // Set the transcoding hints.
  t.setTranscodingHints((Map)hints);
  // Set up the output stream
  TranscoderOutput output = new TranscoderOutput(outputStream);
  // Save the image.
  t.transcode(input, output);
}
origin: hs-web/hsweb-printer

public static void svg2pdf(List<String> svg, OutputStream out) throws Exception {
  TranscoderOutput output = new TranscoderOutput(out);
  PDFPrinter transcoder = new PDFPrinter(svg);
  transcoder.addTranscodingHint(KEY_WIDTH, 800f);
  transcoder.addTranscodingHint(KEY_HEIGHT, 1200f);
  transcoder.addTranscodingHint(KEY_AUTO_FONTS, true);
  final int dpi = 300;
  transcoder.addTranscodingHint(ImageTranscoder.KEY_PIXEL_UNIT_TO_MILLIMETER, 25.4f / dpi);
  transcoder.addTranscodingHint(XMLAbstractTranscoder.KEY_XML_PARSER_VALIDATING, Boolean.FALSE);
  transcoder.addTranscodingHint(PDFTranscoder.KEY_STROKE_TEXT, Boolean.FALSE);
  transcoder.transcode(output);
}
org.apache.batik.transcoderTranscoderOutput<init>

Javadoc

Constructs a new empty TranscoderOutput.

Popular methods of TranscoderOutput

  • getOutputStream
    Returns the output of this transcoder as a byte stream or null if none was supplied.
  • getDocument
    Returns the output of this transcoder as a document or null if none was supplied.
  • getURI
    Returns the output of this transcoder as a URI or null if none was supplied.
  • getWriter
    Returns the output of this transcoder as a character stream or null if none was supplied.
  • getXMLFilter
    Returns the output of this transcoder as a XML filter or null if none was supplied.
  • setOutputStream
    Sets the output of this transcoder output with the specified byte stream.

Popular in Java

  • Making http requests using okhttp
  • findViewById (Activity)
  • setContentView (Activity)
  • getContentResolver (Context)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • TreeMap (java.util)
    A Red-Black tree based NavigableMap implementation. The map is sorted according to the Comparable of
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Pattern (java.util.regex)
    A compiled representation of a regular expression. A regular expression, specified as a string, must
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now