Package com.lowagie.text

Examples of com.lowagie.text.LwgImage


            // 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) {
View Full Code Here


                new URL("http://www.lowagie.com/iText/"));
            document1.add(a2);
            Annotation a3 = new Annotation(250f, 400f, 350f, 500f,
                "http://www.lowagie.com/iText");
            document1.add(a3);
      LwgImage image = LwgImage.getInstance("iText.gif");
      image.setAnnotation(a3);
      document1.add(image);
            Annotation a4 = new Annotation(
                250f, 250f, 350f, 350f, PdfAction.LASTPAGE);
            document1.add(a4);
            // draw rectangles to show where the annotations were added
View Full Code Here

                float x = allColumns[k] - gutter / 2;
                cb.moveTo(x, topColumn);
                cb.lineTo(x, document.bottom());
            }
            cb.stroke();
            LwgImage img = LwgImage.getInstance("cover.png");
            cb.addImage(img, img.getScaledWidth(), 0, 0, img.getScaledHeight(), document.left(), currentY - img.getScaledHeight());
            currentY -= img.getScaledHeight() + 10;
            ct.setYLine(currentY);
            ct.addText(new Chunk("Key Data:", font14B));
            ct.go();
            currentY = ct.getYLine();
            currentY -= 4;
View Full Code Here

     */   
    public void addElement(LwgElement element) {
        if (element == null)
            return;
        if (element instanceof LwgImage) {
            LwgImage img = (LwgImage)element;
            LwgPdfPTable t = new LwgPdfPTable(1);
            float w = img.getWidthPercentage();
            if (w == 0) {
                t.setTotalWidth(img.getScaledWidth());
                t.setLockedWidth(true);
            }
            else
                t.setWidthPercentage(w);
            t.setSpacingAfter(img.getSpacingAfter());
            t.setSpacingBefore(img.getSpacingBefore());
            switch (img.getAlignment()) {
                case LwgImage.LEFT:
                    t.setHorizontalAlignment(LwgElement.ALIGN_LEFT);
                    break;
                case LwgImage.RIGHT:
                    t.setHorizontalAlignment(LwgElement.ALIGN_RIGHT);
                    break;
                default:
                    t.setHorizontalAlignment(LwgElement.ALIGN_CENTER);
                    break;
            }
            LwgPdfPCell c = new LwgPdfPCell(img, true);
            c.setPadding(0);
            c.setBorder(img.getBorder());
            c.setBorderColor(img.getBorderColor());
            c.setBorderWidth(img.getBorderWidth());
            c.setBackgroundColor(img.getBackgroundColor());
            t.add(c);
            element = t;
        }
        if (element.type() == LwgElement.CHUNK) {
          element = new Paragraph((Chunk)element);
View Full Code Here

            template.showText(text);
            template.endText();
            template.setWidth(width);
            template.setHeight(size + 2);
            template.sanityCheck();
            LwgImage img = LwgImage.getInstance(template);
            img.setRotationDegrees(90);
            Chunk ck = new Chunk(img, 0, 0);
            LwgPdfPTable table = new LwgPdfPTable(3);
            table.setWidthPercentage(100);
            table.getDefaultCell().setHorizontalAlignment(LwgElement.ALIGN_CENTER);
            table.getDefaultCell().setVerticalAlignment(LwgElement.ALIGN_MIDDLE);
            LwgPdfPCell cell = new LwgPdfPCell(img);
            cell.setPadding(4);
            cell.setBackgroundColor(new Color(0, 0, 255));
            cell.setHorizontalAlignment(LwgElement.ALIGN_CENTER);
            table.add("I see a template on my right");
            table.add(cell);
            table.add("I see a template on my left");
            table.add(cell);
            table.add("I see a template everywhere");
            table.add(cell);
            table.add("I see a template on my right");
            table.add(cell);
            table.add("I see a template on my left");
           
            Paragraph p1 = new Paragraph("This is a template ");
            p1.add(ck);
            p1.add(" just here.");
            p1.setLeading(img.getScaledHeight() * 1.1f);
            document.add(p1);
            document.add(table);
            Paragraph p2 = new Paragraph("More templates ");
            p2.setLeading(img.getScaledHeight() * 1.1f);
            p2.setAlignment(LwgElement.ALIGN_JUSTIFIED);
            img.scalePercent(70);
            for (int k = 0; k < 20; ++k)
                p2.add(ck);
            document.add(p2);
            // step 5: we close the document
            document.close();
View Full Code Here

           
            // high level
            Paragraph p = new Paragraph();
            for (int i = 0; i < 100; i++) p.add(new Chunk("Blah blah blah blah blah. "));
            document.add(p);
            LwgImage img = LwgImage.getInstance("hitchcock.png");
            img.setAbsolutePosition(100, 500);
            document.add(img);
           
            // low level
            PdfContentByte cb = writer.getDirectContent();
            PdfContentByte cbu = writer.getDirectContentUnder();
View Full Code Here

    String value;

    value = attributes.getProperty(ElementTags.URL);
    if (value == null)
      throw new MalformedURLException(MessageLocalization.getComposedMessage("the.url.of.the.image.is.missing"));
    LwgImage image = LwgImage.getInstance(value);

    value = attributes.getProperty(ElementTags.ALIGN);
    int align = 0;
    if (value != null) {
      if (ElementTags.ALIGN_LEFT.equalsIgnoreCase(value))
        align |= LwgImage.LEFT;
      else if (ElementTags.ALIGN_RIGHT.equalsIgnoreCase(value))
        align |= LwgImage.RIGHT;
      else if (ElementTags.ALIGN_MIDDLE.equalsIgnoreCase(value))
        align |= LwgImage.MIDDLE;
    }
    if ("true".equalsIgnoreCase(attributes
        .getProperty(ElementTags.UNDERLYING)))
      align |= LwgImage.UNDERLYING;
    if ("true".equalsIgnoreCase(attributes
        .getProperty(ElementTags.TEXTWRAP)))
      align |= LwgImage.TEXTWRAP;
    image.setAlignment(align);

    value = attributes.getProperty(ElementTags.ALT);
    if (value != null) {
      image.setAlt(value);
    }

    String x = attributes.getProperty(ElementTags.ABSOLUTEX);
    String y = attributes.getProperty(ElementTags.ABSOLUTEY);
    if ((x != null) && (y != null)) {
      image.setAbsolutePosition(Float.parseFloat(x + "f"), Float
          .parseFloat(y + "f"));
    }
    value = attributes.getProperty(ElementTags.PLAINWIDTH);
    if (value != null) {
      image.scaleAbsoluteWidth(Float.parseFloat(value + "f"));
    }
    value = attributes.getProperty(ElementTags.PLAINHEIGHT);
    if (value != null) {
      image.scaleAbsoluteHeight(Float.parseFloat(value + "f"));
    }
    value = attributes.getProperty(ElementTags.ROTATION);
    if (value != null) {
      image.setRotation(Float.parseFloat(value + "f"));
    }
    return image;
  }
View Full Code Here

            else if (render == SignatureRenderGraphicAndDescription) {
                ColumnText ct2 = new ColumnText(t);
                ct2.setRunDirection(runDirection);
                ct2.setSimpleColumn(signatureRect.getLeft(), signatureRect.getBottom(), signatureRect.getRight(), signatureRect.getTop(), 0, LwgElement.ALIGN_RIGHT);

                LwgImage im = LwgImage.getInstance(signatureGraphic);
                im.scaleToFit(signatureRect.getWidth(), signatureRect.getHeight());

                Paragraph p = new Paragraph();
                // must calculate the point to draw from to make image appear in middle of column
                float x = 0;
                // experimentation found this magic number to counteract Adobe's signature graphic, which
                // offsets the y co-ordinate by 15 units
                float y = -im.getScaledHeight() + 15;

                x = x + (signatureRect.getWidth() - im.getScaledWidth()) / 2;
                y = y - (signatureRect.getHeight() - im.getScaledHeight()) / 2;
                p.add(new Chunk(im, x + (signatureRect.getWidth() - im.getScaledWidth()) / 2, y, false));
                ct2.addElement(p);
                ct2.go();
            }
           
            if (size <= 0) {
View Full Code Here

            ff.setBorderWidth(TextField.BORDER_WIDTH_THIN);
            ff.setText("I'm a form field");
            PdfFormField form = ff.getTextField();
            form.setLayer(l4);
            writer.addAnnotation(form);
            LwgImage img = LwgImage.getInstance("pngnow.png");
            img.setLayer(l4);
            img.setAbsolutePosition(200, 550);
            cb.addImage(img);
            PdfTemplate tp = cb.createTemplate(100, 20);
            LwgPhrase pt = new LwgPhrase("I'm a template", new LwgFont(LwgFont.HELVETICA, 12, LwgFont.NORMAL, Color.magenta));
            ColumnText.showTextAligned(tp, LwgElement.ALIGN_LEFT, pt, 0, 0, 0);
            tp.setLayer(l4);
View Full Code Here

                    if (chunk.isAttribute(Chunk.CHAR_SPACING)) {
                      Float cs = (Float) chunk.getAttribute(Chunk.CHAR_SPACING);
            text.setCharacterSpacing(cs.floatValue());
          }
                    if (chunk.isImage()) {
                        LwgImage image = chunk.getImage();
                        float matrix[] = image.matrix();
                        matrix[LwgImage.CX] = xMarker + chunk.getImageOffsetX() - matrix[LwgImage.CX];
                        matrix[LwgImage.CY] = yMarker + chunk.getImageOffsetY() - matrix[LwgImage.CY];
                        graphics.addImage(image, matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
                        text.moveText(xMarker + lastBaseFactor + image.getScaledWidth() - text.getXTLM(), 0);
                    }
                }
                xMarker += width;
                ++chunkStrokeIdx;
            }
View Full Code Here

TOP

Related Classes of com.lowagie.text.LwgImage

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.