Package org.apache.fop.apps

Examples of org.apache.fop.apps.FopFactory


     * @return the list of {@link EmbedFontInfo} objects
     * @throws FOPException if an error occurs while processing the configuration
     */
    protected List<EmbedFontInfo> buildFontList(Configuration cfg, FontResolver fontResolver,
                    FontEventListener listener) throws FOPException {
        FopFactory factory = userAgent.getFactory();
        FontManager fontManager = factory.getFontManager();
        if (fontResolver == null) {
            //Ensure that we have minimal font resolution capabilities
            fontResolver
                = FontManager.createMinimalFontResolver
                    ( userAgent.isComplexScriptFeaturesEnabled() );
        }

        boolean strict = factory.validateUserConfigStrictly();

        //Read font configuration
        FontInfoConfigurator fontInfoConfigurator
            = new FontInfoConfigurator(cfg, fontManager, fontResolver, listener, strict);
        List<EmbedFontInfo> fontInfoList = new ArrayList<EmbedFontInfo>();
View Full Code Here


        }

        String attributeNS;
        String attributeName;
        String attributeValue;
        FopFactory factory = getFObj().getUserAgent().getFactory();
        for (int i = 0; i < attributes.getLength(); i++) {
            /* convert all attributes with the same namespace as the fo element
             * the "xml:lang" and "xml:base" properties are special cases */
            attributeNS = attributes.getURI(i);
            attributeName = attributes.getQName(i);
            attributeValue = attributes.getValue(i);
            if (attributeNS == null || attributeNS.length() == 0
                    || "xml:lang".equals(attributeName)
                    || "xml:base".equals(attributeName)) {
                convertAttributeToProperty(attributes, attributeName, attributeValue);
            } else if (!factory.isNamespaceIgnored(attributeNS)) {
                ElementMapping mapping = factory.getElementMappingRegistry().getElementMapping(
                        attributeNS);
                QName attr = new QName(attributeNS, attributeName);
                if (mapping != null) {
                    if (mapping.isAttributeProperty(attr)
                            && mapping.getStandardPrefix() != null) {
View Full Code Here

     * @throws FOPException in case of an error during processing
     */
    public void renderTo(FOUserAgent userAgent, String outputFormat, OutputStream out)
                throws FOPException {

        FopFactory factory = userAgent.getFactory();
        Fop fop;
        if (out != null) {
            fop = factory.newFop(outputFormat, userAgent, out);
        } else {
            fop = factory.newFop(outputFormat, userAgent);
        }

        // if base URL was not explicitly set in FOUserAgent, obtain here
        if (fop.getUserAgent().getBaseURL() == null) {
            String baseURL = null;
View Full Code Here

public class MemoryEater {

    private static void eatMemory(File foFile, int replicatorRepeats) throws Exception {

        SAXTransformerFactory tFactory = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
        FopFactory fopFactory = FopFactory.newInstance();
       
        File xsltFile = new File("test/xsl/fo-replicator.xsl");
        Source xslt = new StreamSource(xsltFile);
       
        Source src = new StreamSource(foFile);
       
        Transformer transformer = tFactory.newTransformer(xslt);
        transformer.setParameter("repeats", new Integer(replicatorRepeats));
       
        OutputStream out = new NullOutputStream(); //write to /dev/nul
        Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out);
        Result res = new SAXResult(fop.getDefaultHandler());
       
        transformer.transform(src, res);
       
        System.out.println("Generated " + fop.getResults().getPageCount() + " pages.");
View Full Code Here

            } 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

     */
    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

     * @return  ByteArrayOutputStream containing the binary representation of a PDF document
     * @throws GeneralException
     */
    public static ByteArrayOutputStream render(Writer writer) throws GeneralException {

        FopFactory fopFactory = ApacheFopWorker.getFactoryInstance();
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        TransformerFactory transFactory = TransformerFactory.newInstance();

        try {
            Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out);
            Transformer transformer = transFactory.newTransformer();

            // set the input source (XSL-FO) and generate the PDF
            Reader reader = new StringReader(writer.toString());
            Source src = new StreamSource(reader);

            // Get handler that is used in the generation process
            Result res = new SAXResult(fop.getDefaultHandler());

            try {
                // Transform the FOP XML source into a PDF, hopefully...
                transformer.transform(src, res);

                // We don't want to cache the images that get loaded by the FOP engine
                fopFactory.getImageFactory().clearCaches();

                return out;

            } catch (TransformerException e) {
                Debug.logError("FOP transform failed:" + e, module );
View Full Code Here

    String apacheFopConfiguration = setupApacheFopConfiguration(settings);
    String apacheFopMime = setupApacheFopMime(settings);
    StreamSource foDocumentSrc = new StreamSource(new StringReader(foDocument));
    FopPlaceholderLookup placeholderLookup = null;
    FormattingResults formattingResults = null;
    FopFactory fopFactory = null;
    try {
      fopFactory = getFopFactory(apacheFopConfiguration);
    } catch (FOPException e) {
      throw new Docx4JException("Exception creating fop factory for rendering: " + e.getMessage(), e);
    }
View Full Code Here

    return fop.getResults();
  }
 
  protected Fop createFop(String userConfiguration, String outputFormat, OutputStream outputStream) throws FOPException {
   
    FopFactory fopFactory = getFopFactory(userConfiguration);
    return fopFactory.newFop(outputFormat != null ? outputFormat : MimeConstants.MIME_PDF, outputStream);
  }
View Full Code Here

    try {
      is = IOUtils.toInputStream(userConfig, "UTF-8");
    } catch (IOException e2) {
      e2.printStackTrace();
    }
    FopFactory fopFactory = null;
   
    // If FopConfParser is on path, it is post 1.1
    try {
      Class fopConfParserClass = Class.forName("org.apache.fop.apps.FopConfParser");
     
View Full Code Here

TOP

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

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.