Examples of PdfContentByte


Examples of com.lowagie.text.pdf.PdfContentByte

            // step 2: creation of a writer
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("groups.pdf"));
            // step 3: we open the document
            document.open();
            // step 4: content
            PdfContentByte cb = writer.getDirectContent();
            float gap = (document.getPageSize().getWidth() - 400) / 3;
           
            pictureBackdrop(gap, 500, cb);
            pictureBackdrop(200 + 2 * gap, 500, cb);
            pictureBackdrop(gap, 500 - 200 - gap, cb);
            pictureBackdrop(200 + 2 * gap, 500 - 200 - gap, cb);

            PdfTemplate tp;
            PdfTransparencyGroup group;
           
            tp = cb.createTemplate(200, 200);
            pictureCircles(0, 0, tp);
            group = new PdfTransparencyGroup();
            group.setIsolated(true);
            group.setKnockout(true);
            tp.setGroup(group);
            tp.sanityCheck();
            cb.addTemplate(tp, gap, 500);

           
            tp = cb.createTemplate(200, 200);
            pictureCircles(0, 0, tp);
            group = new PdfTransparencyGroup();
            group.setIsolated(true);
            group.setKnockout(false);
            tp.setGroup(group);
            tp.sanityCheck();
            cb.addTemplate(tp, 200 + 2 * gap, 500);

           
            tp = cb.createTemplate(200, 200);
            pictureCircles(0, 0, tp);
            group = new PdfTransparencyGroup();
            group.setIsolated(false);
            group.setKnockout(true);
            tp.setGroup(group);
            tp.sanityCheck();
            cb.addTemplate(tp, gap, 500 - 200 - gap);

           
            tp = cb.createTemplate(200, 200);
            pictureCircles(0, 0, tp);
            group = new PdfTransparencyGroup();
            group.setIsolated(false);
            group.setKnockout(false);
            tp.setGroup(group);
            tp.sanityCheck();
            cb.addTemplate(tp, 200 + 2 * gap, 500 - 200 - gap);

            cb.sanityCheck();
        }
        catch (Exception de) {
            de.printStackTrace();
        }
        // step 5: we close the document
View Full Code Here

Examples of com.lowagie.text.pdf.PdfContentByte

           
            // step 3: we open the document
            document.open();
           
            // step 4: we grab the ContentByte and do some stuff with it
            PdfContentByte cb = writer.getDirectContent();
           
            BaseFont bf = BaseFont.createFont("Times-Roman", "winansi", false);
           
            // step 5: we create some PdfPatternPainter instances for drawing path, text, or placing image
           
            // LwgImage instance to be placed in PdfPatternPainter canvas. Any nice one?
            LwgImage img = LwgImage.getInstance("pngnow.png");

            PdfPatternPainter p = cb.createPattern(60f, 60f, 60f, 60f);
            PdfPatternPainter p1 = cb.createPattern(60f, 60f, 60f, 60f);
            PdfPatternPainter p2 = cb.createPattern(img.getScaledWidth(), img.getScaledHeight(), img.getScaledWidth(), img.getScaledHeight());
           
           
            // step 6: put your drawing instruction in the painter canvas
           
            // A star pattern taken from Adobe PDF Reference Book p.207
            String star = "0.3 g\n15.000 27.000 m\n"
            + "7.947 5.292 l\n26.413 18.708 l\n"
            + "3.587 18.708 l\n22.053 5.292 l\nf\n"
            + "45.000 57.000 m\n37.947 35.292 l\n"
            + "56.413 48.708 l\n33.587 48.708 l\n"
            + "52.053 35.292 l\nf\n"
            + "0.7 g\n15.000 57.000 m\n"
            + "7.947 35.292 l\n26.413 48.708 l\n"
            + "3.587 48.708 l\n22.053 35.292 l\nf\n"
            + "45.000 27.000 m\n37.947 5.292 l\n"
            + "56.413 18.708 l\n33.587 18.708 l\n"
            + "52.053 5.292 l\nf";
           
            p.setLiteral(star);
           
            // A Pattern with some text drawing
            p1.setGrayFill(0.3f);
            p1.setFontAndSize(bf, 12);
            p1.beginText();
            p1.setTextMatrix(1f, 0f, 0f, 1f, 0f, 0f);
            p1.showText("A B C D");
            p1.endText();
            p1.moveTo(0f, 0f);
            p1.lineTo(60f, 60f);
            p1.stroke();
            p1.sanityCheck();
           
            // A pattern with an image and position
            p2.addImage(img, img.getScaledWidth(), 0f, 0f, img.getScaledHeight(), 0f, 0f);
            p2.setPatternMatrix(1f, 0f, 0f, 1f, 60f, 60f);
            p2.sanityCheck();
           
            // See if we can apply the pattern color to chunk, phrase or paragraph
            PatternColor pat = new PatternColor(p);
            PatternColor pat1 = new PatternColor(p1);
            PatternColor pat2 = new PatternColor(p2);
            String text = "Text with pattern";
            document.add(new Paragraph(text, FontFactory.getFont(FontFactory.HELVETICA, 60, LwgFont.BOLD, new GrayColor(0.3f))));
            document.add(new Paragraph(text, FontFactory.getFont(FontFactory.HELVETICA, 60, LwgFont.BOLD, pat)));
           
            // draw a rectangle filled with star pattern
            cb.setPatternFill(p);
            cb.setGrayStroke(0.0f);
            cb.rectangle(20, 20, 284, 120);
            cb.fillStroke();
           
            // draw some characters filled with star.
            // Note: A gray, rgb, cmyk or spot color should be applied first
            // otherwise, you will not be able to see the character glyph
            // since the glyph path is filled by pattern
            cb.beginText();
            cb.setFontAndSize(bf, 1);
            cb.setTextMatrix(270f, 0f, 0f, 270f, 20f, 100f);
            cb.setGrayFill(0.9f);
            cb.showText("ABC");
            cb.setPatternFill(p);
            cb.moveTextWithLeading(0.0f, 0.0f);
            cb.showText("ABC");
            cb.endText();
            cb.setPatternFill(p);
           
            // draw a circle. Similar to rectangle
            cb.setGrayStroke(0.0f);
            cb.circle(150f, 400f, 150f);
            cb.fillStroke();
           
            // New Page to draw text in the pattern painter's canvas
            document.newPage();
           
            document.add(new Paragraph(text, FontFactory.getFont(FontFactory.HELVETICA, 60, LwgFont.BOLD, new GrayColor(0.3f))));
            document.add(new Paragraph(text, FontFactory.getFont(FontFactory.HELVETICA, 60, LwgFont.BOLD, pat1)));
            // draw a rectangle
            cb.setPatternFill(p1);
            cb.setGrayStroke(0.0f);
            cb.rectangle(0, 0, 284, 120);
            cb.fillStroke();
           
            // draw some characters
            cb.beginText();
            cb.setFontAndSize(bf, 1);
            cb.setTextMatrix(270f, 0f, 0f, 270f, 20f, 100f);
            cb.setGrayFill(0.9f);
            cb.showText("ABC");
            cb.setPatternFill(p1);
            cb.moveTextWithLeading(0.0f, 0.0f);
            cb.showText("ABC");
            cb.endText();
           
            // draw a circle
            cb.setPatternFill(p1);
            cb.setGrayStroke(0.0f);
            cb.circle(150f, 400f, 150f);
            cb.fillStroke();
            cb.sanityCheck();
           
            // New page to place image in the pattern painter's canvas
            document.newPage();
            document.add(new Paragraph(text, FontFactory.getFont(FontFactory.HELVETICA, 60, LwgFont.BOLD, new GrayColor(0.3f))));
            document.add(new Paragraph(text, FontFactory.getFont(FontFactory.HELVETICA, 60, LwgFont.BOLD, pat2)));
            // The original LwgImage for comparison reason.
            // Note: The width and height is the same as bbox in pattern
            cb.addImage(img, img.getScaledWidth(), 0f, 0f, img.getScaledHeight(), 350f, 400f);
           
            // draw a rectangle
            cb.setPatternFill(p2);
            cb.setGrayStroke(0.0f);
            cb.rectangle(60, 60, 300, 120);
            cb.fillStroke();
           
            // draw some characters.
            // Note: if the image fills up the pattern, there's no need to draw text twice
            // since colors in image will be clipped to character glyph path
            cb.beginText();
            cb.setFontAndSize(bf, 1);
            cb.setTextMatrix(270f, 0f, 0f, 270f, 60f, 120f);
            cb.setPatternFill(p2);
            cb.showText("ABC");
            cb.endText();
           
            // draw a circle
            cb.setPatternFill(p2);
            cb.setGrayStroke(0.0f);
            cb.circle(150f, 400f, 150f);
            cb.fillStroke();
           
            cb.sanityCheck();
        }
        catch(Exception e) {
            e.printStackTrace();
        }
       
View Full Code Here

Examples of com.lowagie.text.pdf.PdfContentByte

            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("shading_pattern.pdf"));
            document.open();

            PdfShading shading = PdfShading.simpleAxial(writer, 100, 100, 400, 100, Color.red, Color.cyan);
            PdfShadingPattern shadingPattern = new PdfShadingPattern(shading);
            PdfContentByte cb = writer.getDirectContent();
            BaseFont bf = BaseFont.createFont(BaseFont.TIMES_BOLD, BaseFont.WINANSI, false);
            cb.setShadingFill(shadingPattern);
            cb.beginText();
            cb.setTextMatrix(100, 100);
            cb.setFontAndSize(bf, 40);
            cb.showText("Look at this text!");
            cb.endText();
            PdfShading shadingR = PdfShading.simpleRadial(writer, 200, 500, 50, 300, 500, 100, new Color(255, 247, 148), new Color(247, 138, 107), false, false);
            cb.paintShading(shadingR);
            cb.sanityCheck();
            document.close();
        }
        catch (Exception de) {
            de.printStackTrace();
        }
View Full Code Here

Examples of com.lowagie.text.pdf.PdfContentByte

                new float[]{.929f, .357f, 1, .298f}, new float[]{.941f, .4f, 1, .102f}, 1.374f);
            PdfFunction function3 = PdfFunction.type3(writer, new float[]{0, 1}, null,
                new PdfFunction[]{function1, function2}, new float[]{.708f}, new float[]{1, 0, 0, 1});
            PdfShading shading = PdfShading.type3(writer, new CMYKColor(0, 0, 0, 0),
                new float[]{0, 0, .096f, 0, 0, 1}, null, function3, new boolean[]{true, true});
            PdfContentByte cb = writer.getDirectContent();
            cb.moveTo(316.789f, 140.311f);
            cb.curveTo(303.222f, 146.388f, 282.966f, 136.518f, 279.122f, 121.983f);
            cb.lineTo(277.322f, 120.182f);
            cb.curveTo(285.125f, 122.688f, 291.441f, 121.716f, 298.156f, 119.386f);
            cb.lineTo(336.448f, 119.386f);
            cb.curveTo(331.072f, 128.643f, 323.346f, 137.376f, 316.789f, 140.311f);
            cb.clip();
            cb.newPath();
            cb.saveState();
            cb.concatCTM(27.7843f, 0, 0, -27.7843f, 310.2461f, 121.1521f);
            cb.paintShading(shading);
            cb.restoreState();
           
            cb.sanityCheck();
           
            document.close();
        }
        catch (Exception de) {
            de.printStackTrace();
View Full Code Here

Examples of com.lowagie.text.pdf.PdfContentByte

            // step 2: creation of a writer
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("transparency.pdf"));
            // step 3: we open the document
            document.open();
            // step 4: content
            PdfContentByte cb = writer.getDirectContent();
            float gap = (document.getPageSize().getWidth() - 400) / 3;
           
            pictureBackdrop(gap, 500, cb);
            pictureBackdrop(200 + 2 * gap, 500, cb);
            pictureBackdrop(gap, 500 - 200 - gap, cb);
            pictureBackdrop(200 + 2 * gap, 500 - 200 - gap, cb);
           
            pictureCircles(gap, 500, cb);
            cb.saveState();
            PdfGState gs1 = new PdfGState();
            gs1.setFillOpacity(0.5f);
            cb.setGState(gs1);
            pictureCircles(200 + 2 * gap, 500, cb);
            cb.restoreState();

            PdfTemplate tp = cb.createTemplate(200, 200);
            cb.saveState();
            pictureCircles(0, 0, tp);
            PdfTransparencyGroup group = new PdfTransparencyGroup();
            tp.setGroup(group);
            tp.sanityCheck();
            cb.setGState(gs1);
            cb.addTemplate(tp, gap, 500 - 200 - gap);
            cb.restoreState();

            tp = cb.createTemplate(200, 200);
            cb.saveState();
            PdfGState gs2 = new PdfGState();
            gs2.setFillOpacity(0.5f);
            gs2.setBlendMode(PdfGState.BM_SOFTLIGHT);
            tp.setGState(gs2);
            tp.sanityCheck();
            pictureCircles(0, 0, tp);
            tp.setGroup(group);
            cb.addTemplate(tp, 200 + 2 * gap, 500 - 200 - gap);
            cb.restoreState();

            cb.resetRGBColorFill();
            ColumnText ct = new ColumnText(cb);
            LwgPhrase ph = new LwgPhrase("Ungrouped objects\nObject opacity = 1.0");
            ct.setSimpleColumn(ph, gap, 0, gap + 200, 500, 18, LwgElement.ALIGN_CENTER);
            ct.go();
           
            ph = new LwgPhrase("Ungrouped objects\nObject opacity = 0.5");
            ct.setSimpleColumn(ph, 200 + 2 * gap, 0, 200 + 2 * gap + 200, 500, 18, LwgElement.ALIGN_CENTER);
            ct.go();
           
            ph = new LwgPhrase("Transparency group\nObject opacity = 1.0\nGroup opacity = 0.5\nBlend mode = Normal");
            ct.setSimpleColumn(ph, gap, 0, gap + 200, 500 - 200 - gap, 18, LwgElement.ALIGN_CENTER);
            ct.go();
           
            ph = new LwgPhrase("Transparency group\nObject opacity = 0.5\nGroup opacity = 1.0\nBlend mode = SoftLight");
            ct.setSimpleColumn(ph, 200 + 2 * gap, 0, 200 + 2 * gap + 200, 500 - 200 - gap, 18, LwgElement.ALIGN_CENTER);
            ct.go();
           
            cb.sanityCheck();
        }
        catch (Exception de) {
            de.printStackTrace();
        }
        // step 5: we close the document
View Full Code Here

Examples of com.lowagie.text.pdf.PdfContentByte

                characters.add(code[i] + "\n");
                names.add(name[i] + "\n");
            }
           
            // we grab the ContentByte and do some stuff with it
            PdfContentByte cb = writer.getDirectContent();
           
            ColumnText ct = new ColumnText(cb);
            ct.setSimpleColumn(unicodes, 60, 300, 100, 300 + 28 * 15, 15, LwgElement.ALIGN_CENTER);
            ct.go();
            cb.rectangle(103, 295, 52, 8 + 28 * 15);
            cb.stroke();
            ct.setSimpleColumn(characters, 105, 300, 150, 300 + 28 * 15, 15, LwgElement.ALIGN_RIGHT);
            ct.go();
            ct.setSimpleColumn(names, 160, 300, 500, 300 + 28 * 15, 15, LwgElement.ALIGN_LEFT);
            ct.go();
           
View Full Code Here

Examples of com.lowagie.text.pdf.PdfContentByte

            // step 3: we open the document
            document.open();
           
            // step 4:
            // we grab the contentbyte and do some stuff with it
            PdfContentByte cb = writer.getDirectContent();
           
            PdfTemplate t = cb.createTemplate(600, 800);
            LwgImage caesar = LwgImage.getInstance("caesar_coin.jpg");
            cb.addImage(caesar, 100, 0, 0, 100, 260, 595);
            t.setGrayFill(0.75f);
            t.moveTo(310, 112);
            t.lineTo(280, 60);
            t.lineTo(340, 60);
            t.closePath();
            t.moveTo(310, 790);
            t.lineTo(310, 710);
            t.moveTo(310, 580);
            t.lineTo(310, 122);
            t.stroke();
            cb.addTemplate(t, 0, 0);
           
            ColumnText ct = new ColumnText(cb);
            ct.addText(new LwgPhrase("GALLIA est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur.  Hi omnes lingua, institutis, legibus inter se differunt. Gallos ab Aquitanis Garumna flumen, a Belgis Matrona et Sequana dividit. Horum omnium fortissimi sunt Belgae, propterea quod a cultu atque humanitate provinciae longissime absunt, minimeque ad eos mercatores saepe commeant atque ea quae ad effeminandos animos pertinent important, proximique sunt Germanis, qui trans Rhenum incolunt, quibuscum continenter bellum gerunt.  Qua de causa Helvetii quoque reliquos Gallos virtute praecedunt, quod fere cotidianis proeliis cum Germanis contendunt, cum aut suis finibus eos prohibent aut ipsi in eorum finibus bellum gerunt.\n", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            ct.addText(new LwgPhrase("[Eorum una, pars, quam Gallos obtinere dictum est, initium capit a flumine Rhodano, continetur Garumna flumine, Oceano, finibus Belgarum, attingit etiam ab Sequanis et Helvetiis flumen Rhenum, vergit ad septentriones. Belgae ab extremis Galliae finibus oriuntur, pertinent ad inferiorem partem fluminis Rheni, spectant in septentrionem et orientem solem. Aquitania a Garumna flumine ad Pyrenaeos montes et eam partem Oceani quae est ad Hispaniam pertinet; spectat inter occasum solis et septentriones.]\n", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            ct.addText(new LwgPhrase("Apud Helvetios longe nobilissimus fuit et ditissimus Orgetorix.  Is M. Messala, [et P.] M.  Pisone consulibus regni cupiditate inductus coniurationem nobilitatis fecit et civitati persuasit ut de finibus suis cum omnibus copiis exirent:  perfacile esse, cum virtute omnibus praestarent, totius Galliae imperio potiri.  Id hoc facilius iis persuasit, quod undique loci natura Helvetii continentur:  una ex parte flumine Rheno latissimo atque altissimo, qui agrum Helvetium a Germanis dividit; altera ex parte monte Iura altissimo, qui est inter Sequanos et Helvetios; tertia lacu Lemanno et flumine Rhodano, qui provinciam nostram ab Helvetiis dividit.  His rebus fiebat ut et minus late vagarentur et minus facile finitimis bellum inferre possent; qua ex parte homines bellandi cupidi magno dolore adficiebantur.  Pro multitudine autem hominum et pro gloria belli atque fortitudinis angustos se fines habere arbitrabantur, qui in longitudinem milia passuum CCXL, in latitudinem CLXXX patebant.\n", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            ct.addText(new LwgPhrase("His rebus adducti et auctoritate Orgetorigis permoti constituerunt ea quae ad proficiscendum pertinerent comparare, iumentorum et carrorum quam maximum numerum coemere, sementes quam maximas facere, ut in itinere copia frumenti suppeteret, cum proximis civitatibus pacem et amicitiam confirmare.  Ad eas res conficiendas biennium sibi satis esse duxerunt; in tertium annum profectionem lege confirmant.  Ad eas res conficiendas Orgetorix deligitur.  Is sibi legationem ad civitates suscipit.  In eo itinere persuadet Castico, Catamantaloedis filio, Sequano, cuius pater regnum in Sequanis multos annos obtinuerat et a senatu populi Romani amicus appellatus erat, ut regnum in civitate sua occuparet, quod pater ante habuerit; itemque Dumnorigi Haeduo, fratri Diviciaci, qui eo tempore principatum in civitate obtinebat ac maxime plebi acceptus erat, ut idem conaretur persuadet eique filiam suam in matrimonium dat.  Perfacile factu esse illis probat conata perficere, propterea quod ipse suae civitatis imperium obtenturus esset:  non esse dubium quin totius Galliae plurimum Helvetii possent; se suis copiis suoque exercitu illis regna conciliaturum confirmat.  Hac oratione adducti inter se fidem et ius iurandum dant et regno occupato per tres potentissimos ac firmissimos populos totius Galliae sese potiri posse sperant.\n", FontFactory.getFont(FontFactory.HELVETICA, 12)));
            ct.addText(new LwgPhrase("Ea res est Helvetiis per indicium enuntiata.  Moribus suis Orgetoricem ex vinculis causam dicere coegerunt; damnatum poenam sequi oportebat, ut igni cremaretur.  Die constituta causae dictionis Orgetorix ad iudicium omnem suam familiam, ad hominum milia decem, undique coegit, et omnes clientes obaeratosque suos, quorum magnum numerum habebat, eodem conduxit; per eos ne causam diceret se eripuit.  Cum civitas ob eam rem incitata armis ius suum exequi conaretur multitudinemque hominum ex agris magistratus cogerent, Orgetorix mortuus est; neque abest suspicio, ut Helvetii arbitrantur, quin ipse sibi mortem consciverit.", FontFactory.getFont(FontFactory.HELVETICA, 12)));
           
            float[] left1  = {70,790, 70,60};
            float[] right1 = {300,790, 300,700, 240,700, 240,590, 300,590, 300,106, 270,60};
            float[] left2  = {320,790, 320,700, 380,700, 380,590, 320,590, 320,106, 350,60};
            float[] right2 = {550,790, 550,60};
           
            int status = 0;
            int column = 0;
            while ((status & ColumnText.NO_MORE_TEXT) == 0) {
                if (column == 0) {
                    ct.setColumns(left1, right1);
                    column = 1;
                }
                else {
                    ct.setColumns(left2, right2);
                    column = 0;
                }
                status = ct.go();
                ct.setYLine(790);
                ct.setAlignment(LwgElement.ALIGN_JUSTIFIED);
                status = ct.go();
                if ((column == 0) && ((status & ColumnText.NO_MORE_COLUMN) != 0)) {
                    document.newPage();
                    cb.addTemplate(t, 0, 0);
                    cb.addImage(caesar, 100, 0, 0, 100, 260, 595);
                }
            }
        }
        catch(DocumentException de) {
            System.err.println(de.getMessage());
View Full Code Here

Examples of com.lowagie.text.pdf.PdfContentByte

           
            // step 3: we open the document
            document.open();
           
            // step 4:
            PdfContentByte cb = writer.getDirectContent();
           
            // we create a PdfTemplate
            PdfTemplate template = cb.createTemplate(120, 120);
           
            // we add some graphics
            template.moveTo(30, 10);
            template.lineTo(90, 10);
            template.lineTo(90, 80);
            template.lineTo(110, 80);
            template.lineTo(60, 110);
            template.lineTo(10, 80);
            template.lineTo(30, 80);
            template.closePath();
            template.stroke();
            template.sanityCheck();
           
            // we add the template on different positions
            cb.addTemplate(template, 0, 0);
            cb.addTemplate(template, 0, 1, -1, 0, 200, 600);
            cb.addTemplate(template, .5f, 0, 0, .5f, 100, 400);
            cb.sanityCheck();
           
            // we go to a new page
            document.newPage();
            cb.addTemplate(template, 0, 500);
            cb.addTemplate(template, 2, 0, -1, 2, 200, 300);
            cb.sanityCheck();
        }
        catch(DocumentException de) {
            System.err.println(de.getMessage());
        }
        catch(IOException ioe) {
View Full Code Here

Examples of com.lowagie.text.pdf.PdfContentByte

           
            // step 3: we open the document
            document.open();
           
            // step 4: we grab the ContentByte and do some stuff with it
            PdfContentByte cb = writer.getDirectContent();
            String star = "0.3 g\n15.000 27.000 m\n"
                + "7.947 5.292 l\n26.413 18.708 l\n"
                + "3.587 18.708 l\n22.053 5.292 l\nf\n"
                + "45.000 57.000 m\n37.947 35.292 l\n"
                + "56.413 48.708 l\n33.587 48.708 l\n"
                + "52.053 35.292 l\nf\n"
                + "0.7 g\n15.000 57.000 m\n"
                + "7.947 35.292 l\n26.413 48.708 l\n"
                + "3.587 48.708 l\n22.053 35.292 l\nf\n"
                + "45.000 27.000 m\n37.947 5.292 l\n"
                + "56.413 18.708 l\n33.587 18.708 l\n"
                + "52.053 5.292 l\nf";
            cb.setLiteral(star);
           
            // sanityCheck doesn't check literals.
            //cb.sanityCheck();
        }
        catch(DocumentException de) {
View Full Code Here

Examples of com.lowagie.text.pdf.PdfContentByte

      // step 3: we open the document
      document.open();

      // step 4: we grab the ContentByte and do some stuff with it
      PdfContentByte cb = writer.getDirectContent();

            PdfGState gs = new PdfGState();
            gs.setFillOpacity(0.5f);
            cb.setGState(gs);
      cb.setColorFill(Color.red);
      cb.circle(260.0f, 500.0f, 250.0f);
      cb.fill();
      cb.circle(260.0f, 500.0f, 200.0f);
      cb.fill();
      cb.circle(260.0f, 500.0f, 150.0f);
      cb.fill();
      gs.setFillOpacity(0.2f);
      cb.setGState(gs);
      cb.setColorFill(Color.blue);
      cb.circle(260.0f, 500.0f, 100.0f);
      cb.fill();
      cb.circle(260.0f, 500.0f, 50.0f);
      cb.fill();
     
      cb.sanityCheck();
    } catch (DocumentException de) {
      System.err.println(de.getMessage());
    } catch (IOException ioe) {
      System.err.println(ioe.getMessage());
    }
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.