Examples of PdfTemplate


Examples of com.lowagie.text.pdf.PdfTemplate

        try {
            Image pdfImage = Image.getInstance(image, null);
            pdfImage.setAbsolutePosition(0, 0);
            pdfImage.scaleToFit(width, height);
            PdfTemplate template = this.contentByte.createTemplate(image
                    .getWidth(), image.getHeight());
            template.addImage(pdfImage);
            this.contentByte.addTemplate(template, x, y);
        } catch (BadElementException e) {
            throw new GeracaoBoletoException(e);
        } catch (DocumentException e) {
            throw new GeracaoBoletoException(e);
View Full Code Here

Examples of com.lowagie.text.pdf.PdfTemplate

        PdfWriter writer = PdfWriter.getInstance(document, out);
        document.addAuthor("JFreeChart");
        document.addSubject("Demonstration");
        document.open();
        PdfContentByte cb = writer.getDirectContent();
        PdfTemplate tp = cb.createTemplate(width, height);
        Graphics2D g2 = tp.createGraphics(width, height, mapper);
        Rectangle2D r2D = new Rectangle2D.Double(0, 0, width, height);
        chart.draw(g2, r2D);
        g2.dispose();
        cb.addTemplate(tp, 0, 0);
      }
View Full Code Here

Examples of com.lowagie.text.pdf.PdfTemplate

        try {
            Image pdfImage = Image.getInstance(image, null);
            pdfImage.setAbsolutePosition(0, 0);
            pdfImage.scaleToFit(width, height);
            PdfTemplate template = this.contentByte.createTemplate(image
                    .getWidth(), image.getHeight());
            template.addImage(pdfImage);
            final float leftMargin = this.document.leftMargin();
            this.contentByte.addTemplate(template, leftMargin + x, y);
        } catch (BadElementException e) {
            throw new GeracaoBoletoException(e);
        } catch (DocumentException e) {
View Full Code Here

Examples of com.lowagie.text.pdf.PdfTemplate

    try {
      Image pdfImage = Image.getInstance(image, null);
      pdfImage.setAbsolutePosition(0, 0);
      pdfImage.scaleToFit(width, height);
      PdfTemplate template = contentByte.createTemplate(image.getWidth(), image.getHeight());
      template.addImage(pdfImage);
      final float leftMargin = document.leftMargin();
      contentByte.addTemplate(template, leftMargin + x, y);
    } catch (BadElementException e) {
      throw new GeracaoBoletoException(e);
    } catch (DocumentException e) {
View Full Code Here

Examples of com.lowagie.text.pdf.PdfTemplate

            mapper.insertDirectory("c:\\windows\\fonts");
            // we create a template and a Graphics2D object that corresponds with it
            int w = 150;
            int h = 150;
            PdfContentByte cb = writer.getDirectContent();
            PdfTemplate tp = cb.createTemplate(w, h);
            Graphics2D g2 = tp.createGraphics(w, h, mapper);
            tp.setWidth(w);
            tp.setHeight(h);
            double ew = w/2;
            double eh = h/2;
            Ellipse2D.Double circle, oval, leaf, stem;
            Area circ, ov, leaf1, leaf2, st1, st2;
            circle = new Ellipse2D.Double();
            oval = new Ellipse2D.Double();
            leaf = new Ellipse2D.Double();
            stem = new Ellipse2D.Double();
            circ = new Area(circle);
            ov = new Area(oval);
            leaf1 = new Area(leaf);
            leaf2 = new Area(leaf);
            st1 = new Area(stem);
            st2 = new Area(stem);
            g2.setColor(Color.green);
           
            // Creates the first leaf by filling the intersection of two Area objects created from an ellipse.
            leaf.setFrame(ew-16, eh-29, 15.0, 15.0);
            leaf1 = new Area(leaf);
            leaf.setFrame(ew-14, eh-47, 30.0, 30.0);
            leaf2 = new Area(leaf);
            leaf1.intersect(leaf2);
            g2.fill(leaf1);
           
            // Creates the second leaf.
            leaf.setFrame(ew+1, eh-29, 15.0, 15.0);
            leaf1 = new Area(leaf);
            leaf2.intersect(leaf1);
            g2.fill(leaf2);
           
            g2.setColor(Color.black);
           
            // Creates the stem by filling the Area resulting from the subtraction of two Area objects created from an ellipse.
            stem.setFrame(ew, eh-42, 40.0, 40.0);
            st1 = new Area(stem);
            stem.setFrame(ew+3, eh-47, 50.0, 50.0);
            st2 = new Area(stem);
            st1.subtract(st2);
            g2.fill(st1);
           
            g2.setColor(Color.yellow);
           
            // Creates the pear itself by filling the Area resulting from the union of two Area objects created by two different ellipses.
            circle.setFrame(ew-25, eh, 50.0, 50.0);
            oval.setFrame(ew-19, eh-20, 40.0, 70.0);
            circ = new Area(circle);
            ov = new Area(oval);
            circ.add(ov);
            g2.fill(circ);
           
            g2.setColor(Color.black);
            java.awt.Font thisFont = new java.awt.Font("Arial", java.awt.Font.PLAIN, 18);
            g2.setFont(thisFont);
            String pear = "Pear";
            FontMetrics metrics = g2.getFontMetrics();
            int width = metrics.stringWidth(pear);
            g2.drawString(pear, (w - width) / 2, 20);
            g2.dispose();
            tp.sanityCheck(); // all the g2 content is written to tp, not cb
            cb.addTemplate(tp, 50, 400);
            cb.sanityCheck();
        }
        catch(DocumentException de) {
            System.err.println(de.getMessage());
View Full Code Here

Examples of com.lowagie.text.pdf.PdfTemplate

            // step3
            document.open();
            // step4
           
            // make a PdfTemplate with the vertical text
            PdfTemplate template = writer.getDirectContent().createTemplate(20, 20);
            BaseFont bf = BaseFont.createFont("Helvetica", "winansi", false);
            String text = "Vertical";
            float size = 16;
            float width = bf.getWidthPoint(text, size);
            template.beginText();
            template.setRGBColorFillF(1, 1, 1);
            template.setFontAndSize(bf, size);
            template.setTextMatrix(0, 2);
            template.showText(text);
            template.endText();
            template.setWidth(width);
            template.setHeight(size + 2);
            // make an LwgImage object from the template
            LwgImage img = LwgImage.getInstance(template);
            img.setRotationDegrees(90);
            LwgPdfPTable table = new LwgPdfPTable(3);
            table.setWidthPercentage(100);
View Full Code Here

Examples of com.lowagie.text.pdf.PdfTemplate

        public void onEndPage(PdfWriter writer, Document document)
        {
            /** The headertable. */
            PdfPTable table = new PdfPTable(2);
            /** A template that will hold the total number of pages. */
            PdfTemplate tpl = writer.getDirectContent().createTemplate(100, 100);
            /** The font that will be used. */
            BaseFont helv = null;
            try
            {
                helv = BaseFont.createFont("Helvetica", BaseFont.WINANSI, false);
View Full Code Here

Examples of com.lowagie.text.pdf.PdfTemplate

        if ((pg.getStatus() & java.awt.image.ImageObserver.ABORT) != 0) {
            throw new IOException("java.awt.Image fetch aborted or errored");
        }
        int w = pg.getWidth();
        int h = pg.getHeight();
        PdfTemplate tp = cb.createTemplate(w, h);
        Graphics2D g2d = tp.createGraphics(w, h, true, quality);
        g2d.drawImage(awtImage, 0, 0, null);
        g2d.dispose();
        return getInstance(tp);
    }
View Full Code Here

Examples of com.lowagie.text.pdf.PdfTemplate

        if ((pg.getStatus() & com.google.code.appengine.awt.image.ImageObserver.ABORT) != 0) {
            throw new IOException("com.google.code.appengine.awt.Image fetch aborted or errored");
        }
        int w = pg.getWidth();
        int h = pg.getHeight();
        PdfTemplate tp = cb.createTemplate(w, h);
        Graphics2D g2d = tp.createGraphics(w, h, true, quality);
        g2d.drawImage(awtImage, 0, 0, null);
        g2d.dispose();
        return getInstance(tp);
    }
View Full Code Here

Examples of com.lowagie.text.pdf.PdfTemplate

        try {
            UIDocument doc = (UIDocument) findITextParent(getParent(), UIDocument.class);
            if (doc != null) {
                PdfWriter writer = (PdfWriter) doc.getWriter();
                PdfContentByte cb = writer.getDirectContent();
                PdfTemplate tp = cb.createTemplate(getWidth(), getHeight());
                Graphics2D g2 = tp.createGraphics(getWidth(), getHeight(), new DefaultFontMapper());            
                chart.draw(g2, new Rectangle2D.Double(0, 0, getWidth(), getHeight()));
                g2.dispose();

                image = new ImgTemplate(tp);
            } else {
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.