Examples of DSCComment


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

        }
        return parseDSCComment(name, value);
    }

    private DSCComment parseDSCComment(String name, String value) {
        DSCComment parsed = DSCCommentFactory.createDSCCommentFor(name);
        if (parsed != null) {
            try {
                parsed.parseValue(value);
                return parsed;
            } catch (Exception e) {
                //ignore and fall back to unparsed DSC comment
            }
        }
View Full Code Here

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

        if (line != null) {
            if (eofFound && (line.length() > 0)) {
                throw new DSCException("Content found after EOF");
            }
            if (line.startsWith("%%")) {
                DSCComment comment = parseDSCLine(line);
                if (comment.getEventType() == EOF && isCheckEOF()) {
                    this.eofFound = true;
                }
                this.nextEvent = comment;
            } else if (line.startsWith("%!")) {
                this.nextEvent = new DSCHeaderComment(line.substring(2));
View Full Code Here

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

    /**
     * @see org.apache.xmlgraphics.ps.dsc.NestedDocumentHandler#handle(org.apache.xmlgraphics.ps.dsc.events.DSCEvent, org.apache.xmlgraphics.ps.dsc.DSCParser)
     */
    public void handle(DSCEvent event, DSCParser parser) throws IOException, DSCException {
        if (event.isDSCComment()) {
            DSCComment comment = event.asDSCComment();
            if (DSCConstants.BEGIN_DOCUMENT.equals(comment.getName())) {
                comment.generate(gen);
                parser.setCheckEOF(false);
                comment = parser.nextDSCComment(DSCConstants.END_DOCUMENT, gen);
                if (comment == null) {
                    throw new DSCException("File is not DSC-compliant: Didn't find an "
                            + DSCConstants.END_DOCUMENT);
                }
                comment.generate(gen);
                parser.setCheckEOF(true);
                parser.next();
            } else if (DSCConstants.BEGIN_DATA.equals(comment.getName())) {
                comment.generate(gen);
                parser.setCheckEOF(false);
                comment = parser.nextDSCComment(DSCConstants.END_DATA, gen);
                if (comment == null) {
                    throw new DSCException("File is not DSC-compliant: Didn't find an "
                            + DSCConstants.END_DATA);
                }
                comment.generate(gen);
                parser.setCheckEOF(true);
                parser.next();
            }
        }
    }
View Full Code Here

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

        }
        return parseDSCComment(name, value);
    }

    private DSCComment parseDSCComment(String name, String value) {
        DSCComment parsed = DSCCommentFactory.createDSCCommentFor(name);
        if (parsed != null) {
            try {
                parsed.parseValue(value);
                return parsed;
            } catch (Exception e) {
                //ignore and fall back to unparsed DSC comment
            }
        }
View Full Code Here

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

        if (line != null) {
            if (eofFound && (line.length() > 0)) {
                throw new DSCException("Content found after EOF");
            }
            if (line.startsWith("%%")) {
                DSCComment comment = parseDSCLine(line);
                if (comment.getEventType() == EOF && isCheckEOF()) {
                    this.eofFound = true;
                }
                this.nextEvent = comment;
            } else if (line.startsWith("%!")) {
                this.nextEvent = new DSCHeaderComment(line.substring(2));
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.