Package org.apache.fop.svg

Examples of org.apache.fop.svg.PDFTranscoder


      transcoder = new JPEGTranscoder();
      transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY,
          new Float(0.9));
      break;
    case PDF:
      transcoder = new PDFTranscoder();
      break;
    default:
      // do nothing
      break;
    }
View Full Code Here


      transcoder = new JPEGTranscoder();
      transcoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY,
          new Float(0.9));
      break;
    case PDF:
      transcoder = new PDFTranscoder();
      break;
    default:
      // do nothing
      break;
    }
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

      if (view == null) {
        return;
      }
      Controller.getCurrentController().getViewController().setWaitingCursor(true);
      final SVGGraphics2D g2d = fillSVGGraphics2D(view);
      final PDFTranscoder pdfTranscoder = new PDFTranscoder();
      /*
       * according to https: &aid=1921334&group_id=7118 Submitted By:
       * Frank Spangenberg (f_spangenberg) Summary: Large mind maps
       * produce invalid PDF
       */
      pdfTranscoder.addTranscodingHint(SVGAbstractTranscoder.KEY_MAX_HEIGHT, new Float(19200));
      pdfTranscoder.addTranscodingHint(SVGAbstractTranscoder.KEY_MAX_WIDTH, new Float(19200));
      pdfTranscoder.addTranscodingHint(ImageTranscoder.KEY_PIXEL_UNIT_TO_MILLIMETER, 25.4f/72f/UITools.FONT_SCALE_FACTOR);
      /* end patch */
      final Document doc = g2d.getDOMFactory();
      final Element rootE = doc.getDocumentElement();
      g2d.getRoot(rootE);
      final TranscoderInput input = new TranscoderInput(doc);
      final FileOutputStream ostream = new FileOutputStream(chosenFile);
      final BufferedOutputStream bufStream = new BufferedOutputStream(ostream);
      final TranscoderOutput output = new TranscoderOutput(bufStream);
      pdfTranscoder.transcode(input, output);
      ostream.flush();
      ostream.close();
    }
    catch (final Exception ex) {
      org.freeplane.core.util.LogUtils.warn(ex);
View Full Code Here

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

*/
public class BasicPDFTranscoderTestCase extends AbstractBasicTranscoderTest {

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

        if (transformto != null && transformto.equals(TO_PDF)) {
            try {
                if(respaction != null && respaction.equals(RESPACTION_SHOWURL)) {
                    ByteArrayOutputStream bout = new ByteArrayOutputStream();
                    PDFTranscoder t = new PDFTranscoder();
                    TranscoderInput input = new TranscoderInput(new StringReader(formattedSvg));
                    TranscoderOutput output = new TranscoderOutput(bout);
                    t.transcode(input, output);
                    resp.setCharacterEncoding("UTF-8");
                    resp.setContentType("text/plain");

                    resp.getWriter().write("<object data=\"data:application/pdf;base64," + Base64.encodeBase64(bout.toByteArray()) "\" type=\"application/pdf\"></object>");
                } else {
                    storeInRepository(uuid, rawSvg, transformto, processid, repository);

                    resp.setContentType("application/pdf");
                    if (processid != null) {
                        resp.setHeader("Content-Disposition",
                                "attachment; filename=\"" + processid + ".pdf\"");
                    } else {
                        resp.setHeader("Content-Disposition",
                                "attachment; filename=\"" + uuid + ".pdf\"");
                    }

                    PDFTranscoder t = new PDFTranscoder();
                    TranscoderInput input = new TranscoderInput(new StringReader(formattedSvg));
                    TranscoderOutput output = new TranscoderOutput(resp.getOutputStream());
                    t.transcode(input, output);
                }
            } catch (TranscoderException e) {
                resp.sendError(500, e.getMessage());
            }
        } else if (transformto != null && transformto.equals(TO_PNG)) {
            try {
                if(respaction != null && respaction.equals(RESPACTION_SHOWURL)) {
                    ByteArrayOutputStream bout = new ByteArrayOutputStream();
                    PNGTranscoder t = new PNGTranscoder();
                    t.addTranscodingHint(ImageTranscoder.KEY_MEDIA, "screen");
                    TranscoderInput input = new TranscoderInput(new StringReader(formattedSvg));
                    TranscoderOutput output = new TranscoderOutput(bout);
                    t.transcode(input, output);
                    resp.setCharacterEncoding("UTF-8");
                    resp.setContentType("text/plain");
                    resp.getWriter().write("<img src=\"data:image/png;base64," + Base64.encodeBase64(bout.toByteArray()) + "\">");
                } else {
                    storeInRepository(uuid, rawSvg, transformto, processid, repository);
                    resp.setContentType("image/png");
                    if (processid != null) {
                        resp.setHeader("Content-Disposition", "attachment; filename=\"" + processid + ".png\"");
                    } else {
                        resp.setHeader("Content-Disposition", "attachment; filename=\"" + uuid + ".png\"");
                    }

                    PNGTranscoder t = new PNGTranscoder();
                    t.addTranscodingHint(ImageTranscoder.KEY_MEDIA, "screen");
                    TranscoderInput input = new TranscoderInput(new StringReader(
                            formattedSvg));
                    TranscoderOutput output = new TranscoderOutput(
                            resp.getOutputStream());
                    t.transcode(input, output);
                }
            } catch (TranscoderException e) {
                resp.sendError(500, e.getMessage());
            }
        } else if (transformto != null && transformto.equals(TO_SVG)) {
View Full Code Here

                repository.deleteAssetFromPath(processAsset.getAssetLocation() + assetFullName);

                ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

                if (transformto.equals(TO_PDF)) {
                    PDFTranscoder t = new PDFTranscoder();
                    TranscoderInput input = new TranscoderInput(new StringReader(
                            rawSvg));
                    TranscoderOutput output = new TranscoderOutput(outputStream);
                    t.transcode(input, output);
                } else if (transformto.equals(TO_PNG)) {
                    PNGTranscoder t = new PNGTranscoder();
                    t.addTranscodingHint(ImageTranscoder.KEY_MEDIA, "screen");
                    TranscoderInput input = new TranscoderInput(new StringReader(
                            rawSvg));
                    TranscoderOutput output = new TranscoderOutput(outputStream);
                    try {
                        t.transcode(input, output);
                    } catch (Exception e) {
                        // issue with batik here..do not make a big deal
                        _logger.debug(e.getMessage());
                    }
                } else if(transformto.equals(TO_SVG)) {
View Full Code Here

    }

    protected void makePDF() throws TranscoderException, IOException {

    PDFTranscoder transcoder = new PDFTranscoder();
 
    InputStream in = new java.io.FileInputStream(inFile);
 
    try {
        TranscoderInput input = new TranscoderInput(in);
 
        // Setup output
        OutputStream out = new java.io.FileOutputStream(outFile);
        out = new java.io.BufferedOutputStream(out);
        try {
        TranscoderOutput output = new TranscoderOutput(out);
   
        // Do the transformation
        transcoder.transcode(input, output);
     
        } finally {
          out.close();
        }
    } finally {
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.