Package org.apache.fop.render.intermediate

Examples of org.apache.fop.render.intermediate.IFException


                dataStream.addFontsToCurrentPage(pageFonts);
            }

            dataStream.endPage();
        } catch (IOException ioe) {
            throw new IFException("I/O error in endPage()", ioe);
        }
    }
View Full Code Here


            AFPPageSetup aps = (AFPPageSetup)extension;
            String element = aps.getElementName();
            if (AFPElementMapping.TAG_LOGICAL_ELEMENT.equals(element)) {
                if (this.location != LOC_IN_PAGE_HEADER
                        && this.location != LOC_FOLLOWING_PAGE_SEQUENCE) {
                    throw new IFException(
                        "TLE extension must be in the page header or between page-sequence"
                            + " and the first page: " + aps, null);
                }
                String name = aps.getName();
                String value = aps.getValue();
                dataStream.createTagLogicalElement(name, value);
            } else {
                if (this.location != LOC_IN_PAGE_HEADER) {
                    throw new IFException(
                        "AFP page setup extension encountered outside the page header: " + aps,
                        null);
                }
                if (AFPElementMapping.INCLUDE_PAGE_SEGMENT.equals(element)) {
                    String name = aps.getName();
                    String source = aps.getValue();
                    pageSegmentMap.put(source, name);
                } else if (AFPElementMapping.NO_OPERATION.equals(element)) {
                    String content = aps.getContent();
                    if (content != null) {
                        dataStream.createNoOperation(content);
                    }
                }
            }
        } else if (extension instanceof AFPPageOverlay) {
            AFPPageOverlay ipo = (AFPPageOverlay)extension;
            if (this.location != LOC_IN_PAGE_HEADER) {
                    throw new IFException(
                        "AFP page overlay extension encountered outside the page header: " + ipo,
                        null);
            }
            String overlay = ipo.getName();
            if (overlay != null) {
                dataStream.createIncludePageOverlay(overlay, ipo.getX(), ipo.getY());
            }
        } else if (extension instanceof AFPInvokeMediumMap) {
            if (this.location != LOC_FOLLOWING_PAGE_SEQUENCE
                    && this.location != LOC_IN_PAGE_HEADER) {

                throw new IFException(
                    "AFP IMM extension must be between page-sequence"
                    + " and the first page or child of page-header: "
                    + extension, null);
            }
            AFPInvokeMediumMap imm = (AFPInvokeMediumMap)extension;
            String mediumMap = imm.getName();
            if (mediumMap != null && !mediumMap.equals(lastMediumMap)) {
                dataStream.createInvokeMediumMap(mediumMap);
                lastMediumMap = mediumMap;
            }
        } else if (extension instanceof AFPIncludeFormMap) {
            AFPIncludeFormMap formMap = (AFPIncludeFormMap)extension;
            ResourceAccessor accessor = new DefaultFOPResourceAccessor(
                    getUserAgent(), null, null);
            try {
                getResourceManager().createIncludedResource(formMap.getName(),
                        formMap.getSrc(), accessor,
                        ResourceObject.TYPE_FORMDEF);
            } catch (IOException ioe) {
                throw new IFException(
                        "I/O error while embedding form map resource: " + formMap.getName(), ioe);
            }
        }
    }
View Full Code Here

            }
            gen.resetPrinter();
            gen.setUnitOfMeasure(getResolution());
            gen.setRasterGraphicsResolution(getResolution());
        } catch (IOException e) {
            throw new IFException("I/O error in startDocument()", e);
        }
    }
View Full Code Here

            gen.resetPrinter();
            if (!pclUtil.isPJLDisabled()) {
                gen.universalEndOfLanguage();
            }
        } catch (IOException ioe) {
            throw new IFException("I/O error in endDocument()", ioe);
        }
        super.endDocument();
    }
View Full Code Here

            //Page size
            final long pagewidth = size.width;
            final long pageheight = size.height;
            selectPageFormat(pagewidth, pageheight);
        } catch (IOException ioe) {
            throw new IFException("I/O error in startPage()", ioe);
        }
    }
View Full Code Here

                //ImageWriterUtil.saveAsPNG(this.currentImage, new java.io.File("D:/page.png"));
                Rectangle printArea = this.currentPageDefinition.getLogicalPageRect();
                gen.setCursorPos(0, 0);
                gen.paintBitmap(this.currentImage, printArea.getSize(), true);
            } catch (IOException ioe) {
                throw new IFException("I/O error while encoding page image", ioe);
            } finally {
                this.currentImage = null;
            }
        }
    }
View Full Code Here

    public void endPage() throws IFException {
        try {
            //Eject page
            gen.formFeed();
        } catch (IOException ioe) {
            throw new IFException("I/O error in endPage()", ioe);
        }
    }
View Full Code Here

        builderFactory.setValidating(false);
        try {
            DocumentBuilder builder = builderFactory.newDocumentBuilder();
            this.reusedParts = builder.newDocument();
        } catch (ParserConfigurationException e) {
            throw new IFException("Error while setting up a DOM for SVG generation", e);
        }

        try {
            TransformerHandler toDOMHandler = tFactory.newTransformerHandler();
            toDOMHandler.setResult(new DOMResult(this.reusedParts));
            this.handler = decorate(toDOMHandler);
            this.handler.startDocument();
        } catch (SAXException se) {
            throw new IFException("SAX error in startDocument()", se);
        } catch (TransformerConfigurationException e) {
            throw new IFException(
                    "Error while setting up a TransformerHandler for SVG generation", e);
        }
    }
View Full Code Here

        try {
            //Stop recording parts reused for each page
            this.handler.endDocument();
            this.handler = null;
        } catch (SAXException e) {
            throw new IFException("SAX error in endDocumentHeader()", e);
        }
    }
View Full Code Here

        if (this.multiFileUtil != null) {
            prepareHandlerWithOutputStream(index);
        } else {
            if (this.simpleResult == null) {
                //Only one page is supported with this approach at the moment
                throw new IFException(
                        "Only one page is supported for output with the given Result instance!",
                        null);
            }
            super.setResult(this.simpleResult);
            this.simpleResult = null;
        }

        try {
            handler.startDocument();
            handler.startPrefixMapping("", NAMESPACE);
            handler.startPrefixMapping(XLINK_PREFIX, XLINK_NAMESPACE);
            AttributesImpl atts = new AttributesImpl();
            XMLUtil.addAttribute(atts, "version", "1.1"); //SVG 1.1
            /*
            XMLUtil.addAttribute(atts, "index", Integer.toString(index));
            XMLUtil.addAttribute(atts, "name", name);
            */
            XMLUtil.addAttribute(atts, "width", SVGUtil.formatMptToPt(size.width) + "pt");
            XMLUtil.addAttribute(atts, "height", SVGUtil.formatMptToPt(size.height) + "pt");
            XMLUtil.addAttribute(atts, "viewBox",
                    "0 0 " + SVGUtil.formatMptToPt(size.width)
                    + " " + SVGUtil.formatMptToPt(size.height));
            handler.startElement("svg", atts);

            try {
                Transformer transformer = tFactory.newTransformer();
                Source src = new DOMSource(this.reusedParts.getDocumentElement());
                Result res = new SAXResult(new DelegatingFragmentContentHandler(this.handler));
                transformer.transform(src, res);
            } catch (TransformerConfigurationException tce) {
                throw new IFException("Error setting up a Transformer", tce);
            } catch (TransformerException te) {
                if (te.getCause() instanceof SAXException) {
                    throw (SAXException)te.getCause();
                } else {
                    throw new IFException("Error while serializing reused parts", te);
                }
            }
        } catch (SAXException e) {
            throw new IFException("SAX error in startPage()", e);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.fop.render.intermediate.IFException

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.