Package org.apache.fop.apps

Examples of org.apache.fop.apps.FOUserAgent


        sendPDF(out.toByteArray(), response);
    }
   
    /** @return a new FOUserAgent for FOP */
    protected FOUserAgent getFOUserAgent() {
        FOUserAgent userAgent = fopFactory.newFOUserAgent();
        //Configure foUserAgent as desired
        return userAgent;
    }
View Full Code Here


            task.log(foFile + " -> " + outFile, Project.MSG_INFO);
        }

        boolean success = false;
        try {
            FOUserAgent userAgent = fopFactory.newFOUserAgent();
            userAgent.setBaseURL(this.baseURL);
            inputHandler.renderTo(userAgent, outputFormat, out);
            success = true;
        } catch (Exception ex) {
            throw new BuildException(ex);
        } finally {
View Full Code Here

        super.bind(pList);
        src = pList.get(PR_SRC).getString();
       
        //Additional processing: preload image
        url = ImageFactory.getURL(getSrc());
        FOUserAgent userAgent = getUserAgent();
        ImageFactory fact = userAgent.getFactory().getImageFactory();
        FopImage fopimage = fact.getImage(url, userAgent);
        if (fopimage == null) {
            log.error("Image not available: " + getSrc());
        } else {
            // load dimensions
View Full Code Here

     * @since 1.1.1
     */
    public static void convertFO2PDF( File fo, File pdf, String resourceDir, DocumentModel documentModel )
        throws TransformerException
    {
        FOUserAgent foUserAgent = getDefaultUserAgent( fo, resourceDir );

        if ( documentModel != null && documentModel.getMeta() != null )
        {
            // http://xmlgraphics.apache.org/fop/embedding.html#user-agent
            String authors = documentModel.getMeta().getAllAuthorNames();
            if ( StringUtils.isNotEmpty( authors ) )
            {
                foUserAgent.setAuthor( authors );
            }
            if ( StringUtils.isNotEmpty( documentModel.getMeta().getTitle() ) )
            {
                foUserAgent.setTitle( documentModel.getMeta().getTitle() );
            }
            String keywords = documentModel.getMeta().getAllKeyWords();
            if ( StringUtils.isNotEmpty( keywords ) )
            {
                foUserAgent.setKeywords( keywords );
            }
            if ( StringUtils.isNotEmpty( documentModel.getMeta().getCreator() ) )
            {
                foUserAgent.setCreator( documentModel.getMeta().getCreator() );
            }
            if ( StringUtils.isNotEmpty( documentModel.getMeta().getGenerator() ) )
            {
                foUserAgent.setProducer( documentModel.getMeta().getGenerator() );
            }
            if ( documentModel.getMeta().getCreationDate() != null )
            {
                foUserAgent.setCreationDate( documentModel.getMeta().getCreationDate() );
            }
        }

        if ( foUserAgent.getCreator() == null )
        {
            foUserAgent.setCreator( System.getProperty( "user.name" ) );
        }
        if ( foUserAgent.getCreationDate() == null )
        {
            foUserAgent.setCreationDate( new Date() );
        }

        convertFO2PDF( fo, pdf, resourceDir, foUserAgent );
    }
View Full Code Here

     * @since 1.1.1
     */
    public static void convertFO2PDF( File fo, File pdf, String resourceDir, FOUserAgent foUserAgent )
        throws TransformerException
    {
        FOUserAgent userAgent = ( foUserAgent == null ? getDefaultUserAgent( fo, resourceDir ) : foUserAgent );

        OutputStream out = null;
        try
        {
            try
View Full Code Here

        return url;
    }

    private static FOUserAgent getDefaultUserAgent( File fo, String resourceDir )
    {
        FOUserAgent foUserAgent = FOP_FACTORY.newFOUserAgent();
        foUserAgent.setBaseURL( getBaseURL( fo, resourceDir ) );

        return foUserAgent;
    }
View Full Code Here

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

                ttfFile.getCanonicalPath(), metricsFile.getCanonicalPath()};
        TTFReader.main(args);
        assertTrue(metricsFile.isFile());
       
        FopFactory fopFactory = FopFactory.newInstance();
        FOUserAgent ua = fopFactory.newFOUserAgent();
        PDFRenderer renderer = new PDFRenderer();
        renderer.setUserAgent(ua);
        List fontList = new java.util.ArrayList();
        List triplets = new java.util.ArrayList();
        triplets.add(new FontTriplet(fontFamily, "normal", Font.WEIGHT_NORMAL));
        EmbedFontInfo font = new EmbedFontInfo(
                metricsFile.toURI().toASCIIString(),
                true, triplets,
                ttfFile.toURI().toASCIIString());
        fontList.add(font);
        renderer.addFontList(fontList);
       
        ua.setRendererOverride(renderer);
        OutputStream out = new NullOutputStream();
       
        Fop fop = fopFactory.newFop(null, ua, out);
       
        TransformerFactory tFactory = TransformerFactory.newInstance();
View Full Code Here

        try {
            String uri = eg.getURL();

            //set image data
            FOUserAgent userAgent = eg.getUserAgent();
            ImageManager manager = userAgent.getFactory().getImageManager();
            ImageInfo info = manager.getImageInfo(uri, userAgent.getImageSessionContext());
            if (info == null) {
                log.error("Image could not be found: " + uri);
                return;
            }
View Full Code Here

TOP

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

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.