Examples of FopFactory


Examples of org.apache.fop.apps.FopFactory

    private static Logger logger = Logger.getLogger(Xml2RtfTransformer.class.getName());

   
    @Override
    public void transform() throws Exception {
        FopFactory fopFactory = FopFactory.newInstance();
        FOUserAgent foUserAgent = fopFactory.newFOUserAgent();

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

Examples of org.apache.fop.apps.FopFactory

   
    private static Logger logger = Logger.getLogger(XmlTransformer.class.getName());
   
    @Override
    public void transform() throws Exception {
        FopFactory fopFactory = FopFactory.newInstance();
        FOUserAgent foUserAgent = fopFactory.newFOUserAgent();

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

Examples of org.apache.fop.apps.FopFactory

    }
    return null;
  }

  public File postProcessResult(File result) throws MojoExecutionException {
    final FopFactory fopFactory = FopFactory.newInstance();
    final FOUserAgent userAgent = fopFactory.newFOUserAgent();

    // First transform the cover page
    transformCover();

    // Get properties file from webhelp war
    String warBasename = result.getName().substring(0, result.getName().lastIndexOf('.'));
 
    Properties properties = new Properties();
    InputStream is;
   
    try {
        File f = new File(projectBuildDirectory, "autopdf/pdf.properties");
        is = new FileInputStream( f );
        properties.load(is);
    }
    catch ( Exception e ) {
        System.out.println("Got an Exception: " + e.getMessage());         
    }

    // FOUserAgent can be used to set PDF metadata
    Configuration configuration = loadFOPConfig();
    InputStream in = null;
    OutputStream out = null;
    File targetPdfFile = null;
    try
    {
      String baseURL = sourceDirectory.toURI().toURL().toExternalForm();
      baseURL = baseURL.replace("file:/", "file:///");

      userAgent.setBaseURL(baseURL);
      if (getLog().isDebugEnabled()) {
          getLog().debug("Absolute path is "+baseURL);
      }
      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
View Full Code Here

Examples of org.apache.fop.apps.FopFactory

    //  Really this is an exact copy of the parent impl, except I use
    //  my own version of loadFOPConfig.  Really, I should be able to
    //  overwrite that method.
    //
    public void postProcessResult(File result) throws MojoExecutionException {
        final FopFactory fopFactory = FopFactory.newInstance();
        final FOUserAgent userAgent = fopFactory.newFOUserAgent();

        // First transform the cover page
        transformCover();

        // FOUserAgent can be used to set PDF metadata
        Configuration configuration = loadFOPConfig();
        InputStream in = null;
        OutputStream out = null;

        try
            {
                String baseURL = sourceDirectory.toURI().toURL().toExternalForm();
                baseURL = baseURL.replace("file:/", "file:///");

                userAgent.setBaseURL(baseURL);
                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
View Full Code Here

Examples of org.apache.fop.apps.FopFactory

     */
    public static Fop createFopInstance(OutputStream out, String outputFormat) throws FOPException {
        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);
        }
        return fop;
    }
View Full Code Here

Examples of org.apache.fop.apps.FopFactory

        spf.setValidating(false);
        SAXParser parser;
        parser = spf.newSAXParser();
        foReader = parser.getXMLReader();

        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

Examples of org.apache.fop.apps.FopFactory

        if (fontResolver == null) {
            //Ensure that we have minimal font resolution capabilities
            fontResolver = FontSetup.createMinimalFontResolver();
        }

        FopFactory factory = userAgent.getFactory();
        boolean strict = factory.validateUserConfigStrictly();
        FontCache fontCache = factory.getFontCache();

        List fontInfoList = buildFontListFromConfiguration(cfg,
                userAgent.getFontBaseURL(), fontResolver, strict,
                fontCache);
       
View Full Code Here

Examples of org.apache.fop.apps.FopFactory

    exl.startExport(process, out, null);

    // generate pdf file
    StreamSource source = new StreamSource(new ByteArrayInputStream(out.toByteArray()));
    StreamSource transformSource = new StreamSource(xsltfile);
    FopFactory fopFactory = FopFactory.newInstance();
    FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
    ByteArrayOutputStream outStream = new ByteArrayOutputStream();
    // transform xml
    Transformer xslfoTransformer = getTransformer(transformSource);
    try {
      Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, outStream);
      Result res = new SAXResult(fop.getDefaultHandler());
      xslfoTransformer.transform(source, res);
    } catch (FOPException e) {
      throw new IOException("FOPException occurred", e);
    } catch (TransformerException e) {
View Full Code Here

Examples of org.apache.fop.apps.FopFactory

   
   
    // generate pdf file
    StreamSource source = new StreamSource(new ByteArrayInputStream(out.toByteArray()));
    StreamSource transformSource = new StreamSource(xsltfile);
    FopFactory fopFactory = FopFactory.newInstance();
    ByteArrayOutputStream outStream = new ByteArrayOutputStream();
    // transform xml
    try {
      Transformer xslfoTransformer = TransformerFactory.newInstance().newTransformer(transformSource);
      Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, outStream);
      Result res = new SAXResult(fop.getDefaultHandler());
      xslfoTransformer.transform(source, res);
    } catch (FOPException e) {
      throw new IOException("FOPException occurred", e);
    } catch (TransformerException e) {
View Full Code Here

Examples of org.apache.fop.apps.FopFactory

            } else {
                transformer = factory.newTransformer(stylesheet);
            }
            transformer.setURIResolver(new LocalResolver(transformer.getURIResolver()));
            transformer.transform(src, res);
            FopFactory fopFactory = getFactoryInstance();
            fopFactory.getImageFactory().clearCaches();
        } catch (Exception e) {
            throw new FOPException(e);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.