Examples of DSCComment


Examples of org.apache.xmlgraphics.ps.dsc.events.DSCComment

    public DSCComment nextDSCComment(String name, PSGenerator gen)
                throws IOException, DSCException {
        while (hasNext()) {
            DSCEvent event = nextEvent();
            if (event.isDSCComment()) {
                DSCComment comment = event.asDSCComment();
                if (name.equals(comment.getName())) {
                    return comment;
                }
            }
            if (gen != null) {
                event.generate(gen); //Pipe through to PSGenerator
View Full Code Here

Examples of org.apache.xmlgraphics.ps.dsc.events.DSCComment

     *              by the given event
     */
    public static boolean headerCommentsEndHere(DSCEvent event) {
        switch (event.getEventType()) {
        case DSC_COMMENT:
            DSCComment comment = event.asDSCComment();
            return (comment.getName().equals(DSCConstants.END_COMMENTS));
        case COMMENT:
            String s = ((PostScriptComment)event).getComment();
            if (s == null || s.length() == 0) {
                return true;
            } else {
View Full Code Here

Examples of org.apache.xmlgraphics.ps.dsc.events.DSCComment

    public static DSCComment nextPageOrTrailer(DSCParser parser, PSGenerator gen)
                throws IOException, DSCException {
        while (parser.hasNext()) {
            DSCEvent event = parser.nextEvent();
            if (event.getEventType() == DSC_COMMENT) {
                DSCComment comment = event.asDSCComment();
                if (DSCConstants.PAGE.equals(comment.getName())) {
                    return comment;
                } else if (DSCConstants.TRAILER.equals(comment.getName())) {
                    return comment;
                }
            } else if (event.getEventType() == EOF) {
                //The Trailer may be missing
                return event.asDSCComment();
View Full Code Here

Examples of org.apache.xmlgraphics.ps.dsc.events.DSCComment

                }
            }
        });

        //Skip the prolog and to the first page
        DSCComment pageOrTrailer = parser.nextDSCComment(DSCConstants.PAGE, gen);
        if (pageOrTrailer == null) {
            throw new DSCException("Page expected, but none found");
        }
        parser.setFilter(null); //Remove filter
       
        //Process individual pages (and skip as necessary)
        while (true) {
            DSCCommentPage page = (DSCCommentPage)pageOrTrailer;
            boolean validPage = (page.getPagePosition() >= from && page.getPagePosition() <= to);
            if (validPage) {
                page.setPagePosition(page.getPagePosition() - from + 1);
                page.generate(gen);
                pageCount++;
            }
            pageOrTrailer = DSCTools.nextPageOrTrailer(parser, (validPage ? gen : null));
            if (pageOrTrailer == null) {
                throw new DSCException("File is not DSC-compliant: Unexpected end of file");
            } else if (!DSCConstants.PAGE.equals(pageOrTrailer.getName())) {
                pageOrTrailer.generate(gen);
                break;
            }
        }
       
        //Write the rest
View Full Code Here

Examples of org.apache.xmlgraphics.ps.dsc.events.DSCComment

                    case DSCParserConstants.HEADER_COMMENT:
                    case DSCParserConstants.COMMENT:
                        //ignore
                        break;
                    case DSCParserConstants.DSC_COMMENT:
                        DSCComment comment = event.asDSCComment();
                        if (comment instanceof DSCCommentBoundingBox) {
                            DSCCommentBoundingBox bboxComment = (DSCCommentBoundingBox)comment;
                            if (DSCConstants.BBOX.equals(bboxComment.getName()) && bbox == null) {
                                bbox = (Rectangle2D)bboxComment.getBoundingBox().clone();
                                //BoundingBox is good but HiRes is better so continue
View Full Code Here

Examples of org.apache.xmlgraphics.ps.dsc.events.DSCComment

                //Write original comment that ends the header comments
                event.generate(gen);
                break;
            }
            if (event.isDSCComment()) {
                DSCComment comment = event.asDSCComment();
                if (DSCConstants.LANGUAGE_LEVEL.equals(comment.getName())) {
                    DSCCommentLanguageLevel level = (DSCCommentLanguageLevel)comment;
                    gen.setPSLevel(level.getLanguageLevel());
                }
            }
            event.generate(gen);
        }
       
        //Skip to the FOPFontSetup
        PostScriptComment fontSetupPlaceholder = parser.nextPSComment("FOPFontSetup", gen);
        if (fontSetupPlaceholder == null) {
            throw new DSCException("Didn't find %FOPFontSetup comment in stream");
        }
        PSFontUtils.writeFontDict(gen, fontInfo, fontInfo.getUsedFonts());
        generateForms(resTracker, userAgent, formResources, gen);

        //Skip the prolog and to the first page
        DSCComment pageOrTrailer = parser.nextDSCComment(DSCConstants.PAGE, gen);
        if (pageOrTrailer == null) {
            throw new DSCException("Page expected, but none found");
        }
       
        //Process individual pages (and skip as necessary)
        while (true) {
            DSCCommentPage page = (DSCCommentPage)pageOrTrailer;
            page.generate(gen);
            pageOrTrailer = DSCTools.nextPageOrTrailer(parser, gen);
            if (pageOrTrailer == null) {
                reportInvalidDSC();
            } else if (!DSCConstants.PAGE.equals(pageOrTrailer.getName())) {
                pageOrTrailer.generate(gen);
                break;
            }
        }
       
        //Write the rest
View Full Code Here

Examples of org.apache.xmlgraphics.ps.dsc.events.DSCComment

            //Filter the prolog
            parser.addListener(new DSCListener() {
                public void processEvent(DSCEvent event, DSCParser parser)
                        throws IOException, DSCException {
                    if (event.isDSCComment()) {
                        DSCComment comment = event.asDSCComment();
                        if (DSCConstants.BEGIN_PROLOG.equals(comment.getName())) {
                            //Skip until end of prolog
                            while (parser.hasNext()) {
                                DSCEvent e = parser.nextEvent();
                                if (e.isDSCComment()) {
                                    if (DSCConstants.END_PROLOG.equals(
View Full Code Here

Examples of org.apache.xmlgraphics.ps.dsc.events.DSCComment

     *              by the given event
     */
    public static boolean headerCommentsEndHere(DSCEvent event) {
        switch (event.getEventType()) {
        case DSC_COMMENT:
            DSCComment comment = event.asDSCComment();
            return (comment.getName().equals(DSCConstants.END_COMMENTS));
        case COMMENT:
            String s = ((PostScriptComment)event).getComment();
            if (s == null || s.length() == 0) {
                return true;
            } else {
View Full Code Here

Examples of org.apache.xmlgraphics.ps.dsc.events.DSCComment

    public static DSCComment nextPageOrTrailer(DSCParser parser, PSGenerator gen)
                throws IOException, DSCException {
        while (parser.hasNext()) {
            DSCEvent event = parser.nextEvent();
            if (event.getEventType() == DSC_COMMENT) {
                DSCComment comment = event.asDSCComment();
                if (DSCConstants.PAGE.equals(comment.getName())) {
                    return comment;
                } else if (DSCConstants.TRAILER.equals(comment.getName())) {
                    return comment;
                }
            } else if (event.getEventType() == EOF) {
                //The Trailer may be missing
                return event.asDSCComment();
View Full Code Here

Examples of org.apache.xmlgraphics.ps.dsc.events.DSCComment

                }
            }
        });

        //Skip the prolog and to the first page
        DSCComment pageOrTrailer = parser.nextDSCComment(DSCConstants.PAGE, gen);
        if (pageOrTrailer == null) {
            throw new DSCException("Page expected, but none found");
        }
        parser.setFilter(null); //Remove filter

        //Process individual pages (and skip as necessary)
        while (true) {
            DSCCommentPage page = (DSCCommentPage)pageOrTrailer;
            boolean validPage = (page.getPagePosition() >= from && page.getPagePosition() <= to);
            if (validPage) {
                page.setPagePosition(page.getPagePosition() - from + 1);
                page.generate(gen);
                pageCount++;
            }
            pageOrTrailer = DSCTools.nextPageOrTrailer(parser, (validPage ? gen : null));
            if (pageOrTrailer == null) {
                throw new DSCException("File is not DSC-compliant: Unexpected end of file");
            } else if (!DSCConstants.PAGE.equals(pageOrTrailer.getName())) {
                pageOrTrailer.generate(gen);
                break;
            }
        }

        //Write the rest
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.