Package org.apache.fop.apps

Examples of org.apache.fop.apps.FOUserAgent


   
    /** {@inheritDoc} */
    public void activateLayout() {
        initialize();

        FOUserAgent userAgent = pageSeq.getUserAgent();
        ImageManager imageManager = userAgent.getFactory().getImageManager();
       
        String uri = getExternalDocument().getSrc();
        Integer firstPageIndex = ImageUtil.getPageIndexFromURI(uri);
        boolean hasPageIndex = (firstPageIndex != null);
       
        try {
            ImageInfo info = imageManager.getImageInfo(uri, userAgent.getImageSessionContext());
           
            Object moreImages = info.getCustomObjects().get(ImageInfo.HAS_MORE_IMAGES);
            boolean hasMoreImages = moreImages != null && !Boolean.FALSE.equals(moreImages);
           
            Dimension intrinsicSize = info.getSize().getDimensionMpt();
            ImageLayout layout = new ImageLayout(getExternalDocument(), this, intrinsicSize);

            areaTreeHandler.getAreaTreeModel().startPageSequence(new PageSequence(null));
            if (log.isDebugEnabled()) {
                log.debug("Starting layout");
            }

            makePageForImage(info, layout);
           
            if (!hasPageIndex && hasMoreImages) {
                if (log.isTraceEnabled()) {
                    log.trace("Starting multi-page processing...");
                }
                URI originalURI;
                try {
                    originalURI = new URI(URISpecification.escapeURI(uri));
                    int pageIndex = 1;
                    while (hasMoreImages) {
                        URI tempURI = new URI(originalURI.getScheme(),
                                originalURI.getSchemeSpecificPart(),
                                "page=" + Integer.toString(pageIndex + 1));
                        if (log.isTraceEnabled()) {
                            log.trace("Subimage: " + tempURI.toASCIIString());
                        }
                        ImageInfo subinfo = imageManager.getImageInfo(
                                tempURI.toASCIIString(), userAgent.getImageSessionContext());
                       
                        moreImages = subinfo.getCustomObjects().get(ImageInfo.HAS_MORE_IMAGES);
                        hasMoreImages = moreImages != null && !Boolean.FALSE.equals(moreImages);
                       
                        intrinsicSize = subinfo.getSize().getDimensionMpt();
View Full Code Here


     * @throws TransformerException In case of a XSL transformation problem
     */
    public void convertProjectTeam2PDF(ProjectTeam team, File xslt, File pdf)
                throws IOException, FOPException, TransformerException {
                   
        FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
        // configure foUserAgent as desired

        // Setup output
        OutputStream out = new java.io.FileOutputStream(pdf);
        out = new java.io.BufferedOutputStream(out);
View Full Code Here

    public void convertFO2PDF(File fo, File pdf) throws IOException, FOPException {
       
        OutputStream out = null;
       
        try {
            FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
            // configure foUserAgent as desired
   
            // Setup output stream.  Note: Using BufferedOutputStream
            // for performance reasons (helpful with FileOutputStreams).
            out = new FileOutputStream(pdf);
View Full Code Here

     * @throws IOException In case of an I/O problem
     * @throws FOPException In case of a FOP problem
     */
    public void convertFO2RTF(File fo, File rtf) throws IOException, FOPException {
       
        FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
        // configure foUserAgent as desired

        OutputStream out = null;
       
        try {
View Full Code Here

    /** {@inheritDoc} */
    public Property eval(Property[] args,
                         PropertyInfo pInfo) throws PropertyException {
        StringBuffer sb = new StringBuffer();
        sb.append("cmyk(" + args[0] + "," + args[1] + "," + args[2] + "," + args[3] + ")");
        FOUserAgent ua = (pInfo == null)
                ? null
                : (pInfo.getFO() == null ? null : pInfo.getFO().getUserAgent());
        return ColorProperty.getInstance(ua, sb.toString());
    }
View Full Code Here

    }

    /** {@inheritDoc} */
    public Property eval(Property[] args,
                         PropertyInfo pInfo) throws PropertyException {
        FOUserAgent ua = (pInfo == null)
                ? null
                : (pInfo.getFO() == null ? null : pInfo.getFO().getUserAgent());
        return ColorProperty.getInstance(ua, "system-color(" + args[0] + ")");

    }
View Full Code Here

    public void convertFO2PDF(File fo, File pdf)
        throws FactoryConfigurationError,
               ParserConfigurationException,
               SAXException, IOException {

        FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
        // configure foUserAgent as desired

        OutputStream out = null;
       
        try {
View Full Code Here

        OutputStream out = new java.io.FileOutputStream(pdffile);
        out = new java.io.BufferedOutputStream(out);
        try {
            //Setup fonts and user agent
            FontInfo fontInfo = new FontInfo();
            FOUserAgent userAgent = fopFactory.newFOUserAgent();

            //Construct the AreaTreeModel that will received the individual pages
            AreaTreeModel treeModel = new RenderPagesModel(userAgent,
                    MimeConstants.MIME_PDF, fontInfo, out);
           
View Full Code Here

     * @param xslfoDoc the DOM Document
     * @param pdf the target PDF file
     */
    public void convertDOM2PDF(Document xslfoDoc, File pdf) {
        try {
            FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
            // configure foUserAgent as desired
   
            // Setup output
            OutputStream out = new java.io.FileOutputStream(pdf);
            out = new java.io.BufferedOutputStream(out);
View Full Code Here

     */
    public void convertToIntermediate(Source src, Source xslt, File intermediate)
                throws IOException, FOPException, TransformerException {
       
        //Create a user agent
        FOUserAgent userAgent = fopFactory.newFOUserAgent();
       
        //Create an instance of the target renderer so the XMLRenderer can use its font setup
        Renderer targetRenderer = userAgent.getRendererFactory().createRenderer(
                userAgent, MimeConstants.MIME_PDF);
       
        //Create the XMLRenderer to create the intermediate format (area tree XML)
        XMLRenderer xmlRenderer = new XMLRenderer();
        xmlRenderer.setUserAgent(userAgent);
       
        //Tell the XMLRenderer to mimic the target renderer
        xmlRenderer.mimicRenderer(targetRenderer);
       
        //Make sure the prepared XMLRenderer is used
        userAgent.setRendererOverride(xmlRenderer);
       
        // Setup output
        OutputStream out = new java.io.FileOutputStream(intermediate);
        out = new java.io.BufferedOutputStream(out);
        try {
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.