Package org.apache.fop.svg

Examples of org.apache.fop.svg.PDFTranscoder


  public PdfConverter() {
    super("application/pdf", "pdf");
  }

  protected Transcoder createTranscoder() {
    return new PDFTranscoder();
  }
View Full Code Here


    /**
     * @see org.apache.fop.AbstractBasicTranscoderTestCase#createTranscoder()
     */
    protected Transcoder createTranscoder() {
        return new PDFTranscoder();
    }
View Full Code Here

        } 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);
View Full Code Here

        } 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);
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

    /**
     * @see org.apache.fop.AbstractBasicTranscoderTestCase#createTranscoder()
     */
    protected Transcoder createTranscoder() {
        return new PDFTranscoder();
    }
View Full Code Here

   * @param file Output filename
   * @throws IOException On write errors
   * @throws TranscoderException On input/parsing errors.
   */
  public void saveAsPDF(File file) throws IOException, TranscoderException {
    transcode(file, new PDFTranscoder());
  }
View Full Code Here

  }

  private static byte[] getPDFByteArray(final Document document, final int width)
  {
    // Create a pdf transcoder
    final PDFTranscoder t = new PDFTranscoder();
    t.addTranscodingHint(PDFTranscoder.KEY_AUTO_FONTS, false);
    t.addTranscodingHint(PDFTranscoder.KEY_WIDTH, new Float(width));
    TranscoderInput input = new TranscoderInput(document);
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final TranscoderOutput output = new TranscoderOutput(baos);
    // Save the image.
    try {
      t.transcode(input, output);
    } catch (TranscoderException ex) {
      log.fatal("Exception encountered " + ex, ex);
    }
    return baos.toByteArray();
  }
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.fop.svg.PDFTranscoder

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.