Package org.apache.fop.apps

Examples of org.apache.fop.apps.Fop


        OutputStream out = new FileOutputStream(target);
        out = new BufferedOutputStream(out);
       
        try {
            Fop fop = fopFactory.newFop(MimeConstants.MIME_RTF, foUserAgent, out);
            TransformerFactory factory = TransformerFactory.newInstance();
           
            javax.xml.transform.Transformer transformer =
                    factory.newTransformer(new StreamSource(template));
           
            transformer.setErrorListener(this);
            transformer.setParameter("versionParam", "1.0");
            transformer.transform(new StreamSource(source), new SAXResult(fop.getDefaultHandler()));
        } finally {
            out.close();
        }
    }
View Full Code Here


        OutputStream out = new FileOutputStream(target);
        out = new BufferedOutputStream(out);
       
        try {
            Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
            TransformerFactory factory = TransformerFactory.newInstance();
           
            javax.xml.transform.Transformer transformer =
                    factory.newTransformer(new StreamSource(template));
           
            transformer.setErrorListener(this);
            transformer.setParameter("versionParam", "1.0");
            transformer.transform(new StreamSource(source), new SAXResult(fop.getDefaultHandler()));
        } finally {
            out.close();
        }
    }
View Full Code Here

      in = new FileInputStream(result);

      targetPdfFile = new File (result.getAbsolutePath().replaceAll(".fo$", properties.getProperty("pdfsuffix","") + ".pdf"));
      out = new FileOutputStream(targetPdfFile);
      fopFactory.setUserConfig(configuration);
      Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, userAgent, out);

      // Setup JAXP using identity transformer
      TransformerFactory factory = TransformerFactory.newInstance();
      Transformer transformer = factory.newTransformer(); // identity transformer

      // Setup input stream
      Source src = new StreamSource(in);

      // Resulting SAX events (the generated FO) must be piped through to FOP
      Result res = new SAXResult(fop.getDefaultHandler());

      // Start XSLT transformation and FOP processing
      transformer.transform(src, res);
     
     
View Full Code Here

                System.err.println ("Absolute path is "+baseURL);

                in = openFileForInput(result);
                out = openFileForOutput(getOutputFile(result));
                fopFactory.setUserConfig(configuration);
                Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, userAgent, out);

                // Setup JAXP using identity transformer
                TransformerFactory factory = TransformerFactory.newInstance();
                Transformer transformer = factory.newTransformer(); // identity transformer

                // Setup input stream
                Source src = new StreamSource(in);

                // Resulting SAX events (the generated FO) must be piped through to FOP
                Result res = new SAXResult(fop.getDefaultHandler());

                // Start XSLT transformation and FOP processing
                transformer.transform(src, res);
            }
        catch (FOPException e)
View Full Code Here

        }
        Reader reader = new StringReader(screenOutString);
        StreamSource src = new StreamSource(reader);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            Fop fop = ApacheFopWorker.createFopInstance(out, contentType);
            ApacheFopWorker.transform(src, null, fop);
        } catch (Exception e) {
            renderError("Unable to transform FO file", e, screenOutString, request, response);
            return;
        }
View Full Code Here

     */
    public static void transform(File srcFile, File destFile, File stylesheetFile, String outputFormat) throws IOException, FOPException {
        StreamSource src = new StreamSource(srcFile);
        StreamSource stylesheet = stylesheetFile == null ? null : new StreamSource(stylesheetFile);
        BufferedOutputStream dest = new BufferedOutputStream(new FileOutputStream(destFile));
        Fop fop = createFopInstance(dest, outputFormat);
        if (fop.getUserAgent().getBaseURL() == null) {
            String baseURL = null;
            try {
                File parentFile = new File(srcFile.getAbsolutePath()).getParentFile();
                baseURL = parentFile.toURI().toURL().toExternalForm();
            } catch (Exception e) {
                baseURL = "";
            }
            fop.getUserAgent().setBaseURL(baseURL);
        }
        transform(src, stylesheet, fop);
        dest.close();
    }
View Full Code Here

     * @param outputFormat Optional output format, defaults to "application/pdf"
     */
    public static void transform(InputStream srcStream, OutputStream destStream, InputStream stylesheetStream, String outputFormat) throws FOPException {
        StreamSource src = new StreamSource(srcStream);
        StreamSource stylesheet = stylesheetStream == null ? null : new StreamSource(stylesheetStream);
        Fop fop = createFopInstance(destStream, outputFormat);
        transform(src, stylesheet, fop);
    }
View Full Code Here

        if (UtilValidate.isEmpty(outputFormat)) {
            outputFormat = MimeConstants.MIME_PDF;
        }
        FopFactory fopFactory = getFactoryInstance();
        FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
        Fop fop;
        if (out != null) {
            fop = fopFactory.newFop(outputFormat, foUserAgent, out);
        } else {
            fop = fopFactory.newFop(outputFormat, foUserAgent);
        }
View Full Code Here

                    StreamSource src = new StreamSource(new StringReader(writer.toString()));

                    // create the output stream for the generation
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();

                    Fop fop = ApacheFopWorker.createFopInstance(baos, MimeConstants.MIME_PDF);
                    ApacheFopWorker.transform(src, null, fop);

                    // and generate the PDF
                    baos.flush();
                    baos.close();
View Full Code Here

        FopFactory fopFactory = FopFactory.newInstance();
        FOUserAgent ua = fopFactory.newFOUserAgent();
        tableHandler = new TableHandler(ua);
        ua.setFOEventHandlerOverride(tableHandler);

        Fop fop = fopFactory.newFop(ua);

        foReader.setContentHandler(fop.getDefaultHandler());
        foReader.setDTDHandler(fop.getDefaultHandler());
        foReader.setErrorHandler(fop.getDefaultHandler());
        foReader.setEntityResolver(fop.getDefaultHandler());
    }
View Full Code Here

TOP

Related Classes of org.apache.fop.apps.Fop

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.