Examples of PdfGraphics2D


Examples of org.apache.fop.svg.PDFGraphics2D

        }*/

        if (pdfInfo.pdfContext == null) {
            pdfInfo.pdfContext = pdfInfo.pdfPage;
        }
        PDFGraphics2D graphics = new PDFGraphics2D(true, pdfInfo.fi,
                pdfInfo.pdfDoc,
                pdfInfo.pdfContext, pdfInfo.pdfPage.referencePDF(),
                pdfInfo.currentFontName, pdfInfo.currentFontSize);
        graphics.setGraphicContext(new org.apache.batik.ext.awt.g2d.GraphicContext());
        pdfInfo.pdfState.push();
        AffineTransform transform = new AffineTransform();
        // scale to viewbox
        transform.translate(xOffset / 1000f, yOffset / 1000f);

        if (deviceResolution != uaResolution) {
            //Scale for higher resolution on-the-fly images from Batik
            double s = uaResolution / deviceResolution;
            at.scale(s, s);
            pdfInfo.currentStream.add("" + PDFNumber.doubleOut(s) + " 0 0 "
                                + PDFNumber.doubleOut(s) + " 0 0 cm\n");
            graphics.scale(1 / s, 1 / s);
        }

        pdfInfo.pdfState.setTransform(transform);
        graphics.setPDFState(pdfInfo.pdfState);
        graphics.setOutputStream(pdfInfo.outputStream);
        try {
            root.paint(graphics);
            pdfInfo.currentStream.add(graphics.getString());
        } catch (Exception e) {
            log.error("svg graphic could not be rendered: "
                                   + e.getMessage(), e);
        }

View Full Code Here

Examples of org.apache.fop.svg.PDFGraphics2D

            }

            if (pdfInfo.pdfContext == null) {
                pdfInfo.pdfContext = pdfInfo.pdfPage;
            }
            PDFGraphics2D graphics = new PDFGraphics2D(true, pdfInfo.fi, pdfInfo.pdfDoc,
                                     pdfInfo.pdfContext, pdfInfo.pdfPage.referencePDF(),
                                     pdfInfo.currentFontName,
                                     pdfInfo.currentFontSize);
            graphics.setGraphicContext(new org.apache.batik.ext.awt.g2d.GraphicContext());
            pdfInfo.pdfState.push();
            AffineTransform transform = new AffineTransform();
            // scale to viewbox
            transform.translate(xOffset / 1000f, yOffset / 1000f);

            if (deviceResolution != uaResolution) {
                //Scale for higher resolution on-the-fly images from Batik
                double s = uaResolution / deviceResolution;
                at.scale(s, s);
                pdfInfo.currentStream.add("" + PDFNumber.doubleOut(s) + " 0 0 "
                                    + PDFNumber.doubleOut(s) + " 0 0 cm\n");
                graphics.scale(1 / s, 1 / s);
            }

            pdfInfo.pdfState.setTransform(transform);
            graphics.setPDFState(pdfInfo.pdfState);
            graphics.setOutputStream(pdfInfo.outputStream);
            try {
                root.paint(graphics);
                pdfInfo.currentStream.add(graphics.getString());
            } catch (Exception e) {
                log.error("svg graphic could not be rendered: "
                                       + e.getMessage(), e);
            }
View Full Code Here

Examples of org.apache.fop.svg.PDFGraphics2D

        renderer.currentStream.add(sx + " 0 0 " + sy + " " + fx + " "
                          + fy + " cm\n");


        final boolean textAsShapes = false;
        PDFGraphics2D graphics = new PDFGraphics2D(textAsShapes,
                pdfInfo.fi, pdfInfo.pdfDoc,
                pdfInfo.pdfContext, pdfInfo.pdfPage.referencePDF(),
                renderer.currentFontName,
                renderer.currentFontSize);
        graphics.setGraphicContext(new org.apache.batik.ext.awt.g2d.GraphicContext());
       
        AffineTransform transform = new AffineTransform();
        transform.translate(fx, fy);
        pdfInfo.pdfState.setTransform(transform);
        graphics.setPDFState(pdfInfo.pdfState);
        graphics.setOutputStream(pdfInfo.outputStream);

        Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, imw, imh);
        painter.paint(graphics, area);

        pdfInfo.currentStream.add(graphics.getString());
        renderer.restoreGraphicsState();
        pdfInfo.pdfState.pop();
   
    }
View Full Code Here

Examples of org.foray.graphic.batik.PDFGraphics2D

        GraphicsNode root;
        root = builder.build(ctx, svgDocument);
        ctx = null;
        builder = null;

        PDFGraphics2D graphics;
        try {
            graphics = new PDFGraphics2D(true, svgDocument,
                    fontConsumer, this.svg.getLogger(), pdfContext, outputStream);
        } catch (final GraphicException e) {
            /* This exception is caused when no graphical environment exists. We check for that at
             * the beginning of this method, so this should never happen. */
            return null;
        }
        graphics.setGraphicContext(
                new org.apache.batik.ext.awt.g2d.GraphicContext());

        root.paint(graphics);
        return graphics;
    }
View Full Code Here

Examples of org.foray.graphic.batik.PDFGraphics2D

            final GraphicOutputContext outputContext,
            final FontConsumer fontConsumer, final boolean strokeText,
            final boolean commentsEnabled) throws GraphicException {
        SVGDocument doc = null;
        doc = this.svg.getSvgDocument();
        final PDFGraphics2D graphics = getPDFContent4SVG(fontConsumer, doc,
                strokeText, outputContext, output);
        if (graphics == null) {
            throw new GraphicException("Unable to convert to PDF: "
                    + this.svg.getUrl().toExternalForm());
        }
        graphics.dispose();
        if (graphics.ioErrorFound()) {
            throw new GraphicException("I/O error(s) while converting to PDF: "
                    + this.svg.getUrl().toExternalForm());
        }
    }
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.