Package com.lowagie.text.pdf

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


           
            // 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

      // 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

           
            // step 3: we open the document
            document.open();
           
            // step 4:
            PdfContentByte cb = writer.getDirectContent();
            cb.transform(AffineTransform.getScaleInstance(1.2, 0.75));
           
            // we create a PdfTemplate
            PdfTemplate template = cb.createTemplate(25, 25);
           
            // we add some crosses to visualize the coordinates
            template.moveTo(13, 0);
            template.lineTo(13, 25);
            template.moveTo(0, 13);
            template.lineTo(50, 13);
            template.stroke();
            template.sanityCheck();
           
            // we add the template on different positions
            cb.addTemplate(template, 216 - 13, 720 - 13);
            cb.addTemplate(template, 360 - 13, 360 - 13);
            cb.addTemplate(template, 360 - 13, 504 - 13);
            cb.addTemplate(template, 72 - 13, 144 - 13);
            cb.addTemplate(template, 144 - 13, 288 - 13);

            cb.moveTo(216, 720);
            cb.lineTo(360, 360);
            cb.lineTo(360, 504);
            cb.lineTo(72, 144);
            cb.lineTo(144, 288);
            cb.stroke();
           
            BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
            cb.beginText();
            cb.setFontAndSize(bf, 12);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "(3\" * 1.2, 10\" * .75)", 216 + 25, 720 + 5, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "(5\" * 1.2, 5\" * .75)", 360 + 25, 360 + 5, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "(5\" * 1.2, 7\" * .75)", 360 + 25, 504 + 5, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "(1\" * 1.2, 2\" * .75)", 72 + 25, 144 + 5, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "(2\" * 1.2, 4\" * .75)", 144 + 25, 288 + 5, 0);
            cb.endText();
           
            cb.sanityCheck();
        }
        catch(DocumentException de) {
            System.err.println(de.getMessage());
        }
        catch(IOException ioe) {
View Full Code Here

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

            cb.circle(250.0f, 500.0f, 200.0f);
            cb.circle(250.0f, 500.0f, 150.0f);
            cb.stroke();
            cb.setRGBColorFill(0xFF, 0x00, 0x00);
            cb.circle(250.0f, 500.0f, 100.0f);
            cb.fillStroke();
            cb.setRGBColorFill(0xFF, 0xFF, 0xFF);
            cb.circle(250.0f, 500.0f, 50.0f);
            cb.fill();
           
            cb.sanityCheck();
        }
        catch(DocumentException de) {
            System.err.println(de.getMessage());
        }
        catch(IOException ioe) {
View Full Code Here

            writer.setPdfVersion(PdfWriter.VERSION_1_5);
            writer.setViewerPreferences(PdfWriter.PageModeUseOC);
            // step 3
            document.open();
            // step 4
            PdfContentByte cb = writer.getDirectContent();
            LwgPhrase explanation = new LwgPhrase("Layer grouping", new LwgFont(LwgFont.HELVETICA, 20, LwgFont.BOLD, Color.red));
            ColumnText.showTextAligned(cb, LwgElement.ALIGN_LEFT, explanation, 50, 650, 0);
            PdfLayer l1 = new PdfLayer("Layer 1", writer);
            PdfLayer l2 = new PdfLayer("Layer 2", writer);
            PdfLayer l3 = new PdfLayer("Layer 3", writer);
            PdfLayerMembership m1 = new PdfLayerMembership(writer);
            m1.addMember(l2);
            m1.addMember(l3);
            LwgPhrase p1 = new LwgPhrase("Text in layer 1");
            LwgPhrase p2 = new LwgPhrase("Text in layer 2 or layer 3");
            LwgPhrase p3 = new LwgPhrase("Text in layer 3");
            cb.beginLayer(l1);
            ColumnText.showTextAligned(cb, LwgElement.ALIGN_LEFT, p1, 50, 600, 0);
            cb.endLayer();
            cb.beginLayer(m1);
            ColumnText.showTextAligned(cb, LwgElement.ALIGN_LEFT, p2, 50, 550, 0);
            cb.endLayer();
            cb.beginLayer(l3);
            ColumnText.showTextAligned(cb, LwgElement.ALIGN_LEFT, p3, 50, 500, 0);
            cb.endLayer();
            cb.sanityCheck();
           
            PdfOCProperties p = writer.getOCProperties();
            PdfArray order = new PdfArray();
            order.add(l1.getRef());
            PdfArray group = new PdfArray();
View Full Code Here

   *
   * @see com.lowagie.text.pdf.PdfPageEventHelper#onGenericTag(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document, com.lowagie.text.LwgRectangle, java.lang.String)
   */
  public void onGenericTag(PdfWriter writer, LwgDocument document, LwgRectangle rect, String text) {
    if ("ellipse".equals(text)) {
      PdfContentByte cb = writer.getDirectContent();
      cb.setRGBColorStroke(0xFF, 0x00, 0x00);
      cb.ellipse(rect.getLeft(), rect.getBottom() - 5f, rect.getRight(), rect.getTop());
      cb.stroke();
      cb.resetRGBColorStroke();
    }
    else if ("box".equals(text)) {
      PdfContentByte cb = writer.getDirectContentUnder();
      rect.setGrayFill(0.5f);
      cb.rectangle(rect);
    }
    }
View Full Code Here

     * @param document
     * @param position
     */
    public void onParagraph(PdfWriter writer, LwgDocument document, float position) {
        n++;
        PdfContentByte cb = writer.getDirectContent();
        PdfDestination destination = new PdfDestination(PdfDestination.FITH, position);
        new PdfOutline(cb.getRootOutline(), destination, "paragraph " + n);
    }
View Full Code Here

            // step 2: creation of a writer
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("softmask.pdf"));
            // step 3: we open the document
            document.open();
            // step 4: content
            PdfContentByte cb = writer.getDirectContent();
            String text = "text ";
            text += text;
            text += text;
            text += text;
            text += text;
            text += text;
            text += text;
            text += text;
            text += text;
            document.add(new Paragraph(text));
            LwgImage img = LwgImage.getInstance("otsoe.jpg");
            img.setAbsolutePosition(100, 550);
            byte gradient[] = new byte[256];
            for (int k = 0; k < 256; ++k)
                gradient[k] = (byte)k;
            LwgImage smask = LwgImage.getInstance(256, 1, 1, 8, gradient);
            smask.makeMask();
            img.setImageMask(smask);
            cb.addImage(img);
            cb.sanityCheck();
        }
        catch (Exception de) {
            de.printStackTrace();
        }
        // step 5: we close the document
View Full Code Here

           
            // step 3: we open the document
            document.open();
           
            // step 4:
            PdfContentByte cb = writer.getDirectContent();
            LwgImage img = LwgImage.getInstance("hitchcock.png");
            cb.addImage(img, 271, -50, -30, 550, 100, 100);
            cb.sanityCheck();
  
        }
        catch(DocumentException de) {
            System.err.println(de.getMessage());
        }
View Full Code Here

TOP

Related Classes of com.lowagie.text.pdf.PdfContentByte

Copyright © 2018 www.massapicom. 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.