daily pastebin goal
23%
SHARE
TWEET

Untitled

a guest Aug 17th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static void convert(String svg, String destination, int factor) throws IOException, TranscoderException {
  2.  
  3.         String svg_URI_input = Paths.get(svg).toUri().toURL().toString();
  4.         TranscoderInput input_svg_image = new TranscoderInput(svg_URI_input);
  5.         OutputStream png_ostream = new FileOutputStream(destination);
  6.         TranscoderOutput output_png_image = new TranscoderOutput(png_ostream);
  7.  
  8.         PNGTranscoder my_converter  = new PNGTranscoder();
  9.         Map<TranscodingHints.Key, Float> hints =
  10.                 new HashMap<TranscodingHints.Key, Float>();
  11.         my_converter.addTranscodingHint( PNGTranscoder.KEY_WIDTH, new Float( 3607*factor ) );
  12.         my_converter.addTranscodingHint( PNGTranscoder.KEY_HEIGHT, new Float( 631*factor ) );
  13.         my_converter.setTranscodingHints(hints);
  14.         my_converter.transcode(input_svg_image, output_png_image);
  15.         png_ostream.flush();
  16.         png_ostream.close();
  17.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top