Package com.lowagie.text

Examples of com.lowagie.text.LwgImage


           
            // step 3: we open the document
            document.open();
           
            // step 4: content
            LwgImage gif = LwgImage.getInstance("vonnegut.gif");
            gif.setAlignment(LwgImage.RIGHT | LwgImage.TEXTWRAP);
            LwgImage jpeg = LwgImage.getInstance("otsoe.jpg");
            jpeg.setAlignment(LwgImage.MIDDLE);
            LwgImage png = LwgImage.getInstance("hitchcock.png");
            png.setAlignment(LwgImage.LEFT | LwgImage.UNDERLYING);
           
            for (int i = 0; i < 100; i++) {
                document.add(new LwgPhrase("Who is this? "));
            }
            document.add(gif);
View Full Code Here


            for (int i = 0; i < 300; i++) {
                document.add(new LwgPhrase("Who is this? "));
            }
            PdfContentByte cb = writer.getDirectContent();
            java.awt.Image awtImage = Toolkit.getDefaultToolkit().createImage("H.gif");
            LwgImage image = LwgImage.getInstance(awtImage, null);
            image.setAbsolutePosition(100, 500);
            cb.addImage(image);
            LwgImage gif = LwgImage.getInstance(awtImage, new Color(0x00, 0xFF, 0xFF), true);
            gif.setAbsolutePosition(300, 500);
            cb.addImage(gif);
            LwgImage img1 = LwgImage.getInstance(awtImage, null, true);
            img1.setAbsolutePosition(100, 200);
            cb.addImage(img1);
            LwgImage img2 = LwgImage.getInstance(awtImage, new Color(0xFF, 0xFF, 0x00), false);
            img2.setAbsolutePosition(300, 200);
            cb.addImage(img2);
        }
        catch(DocumentException de) {
            System.err.println(de.getMessage());
        }
View Full Code Here

            // step 3: we open the document
            document.open();
           
            // step 4:
            document.add(new Paragraph("A picture of my dog: otsoe.jpg"));
            LwgImage jpg = LwgImage.getInstance("otsoe.jpg");
            document.add(jpg);
            document.add(new Paragraph("getacro.gif"));
            LwgImage gif= LwgImage.getInstance("getacro.gif");
            document.add(gif);
            document.add(new Paragraph("pngnow.png"));
            LwgImage png = LwgImage.getInstance("pngnow.png");
            document.add(png);
            document.add(new Paragraph("iText.bmp"));
            LwgImage bmp = LwgImage.getInstance("iText.bmp");
            document.add(bmp);
            document.add(new Paragraph("iText.wmf"));
            LwgImage wmf = LwgImage.getInstance("iText.wmf");
            document.add(wmf);
            document.add(new Paragraph("iText.tif"));
            LwgImage tiff = LwgImage.getInstance("iText.tif");
            document.add(tiff);
        }
        catch(DocumentException de) {
            System.err.println(de.getMessage());
        }
View Full Code Here

            document.add(p);
            document.add(p);
            document.add(p);
            PdfContentByte cb = writer.getDirectContent();
            byte maskr[] = {(byte)0x3c, (byte)0x7e, (byte)0xe7, (byte)0xc3, (byte)0xc3, (byte)0xe7, (byte)0x7e, (byte)0x3c};
            LwgImage mask = LwgImage.getInstance(8, 8, 1, 1, maskr);
            mask.makeMask();
            mask.setInverted(true);
            LwgImage image = LwgImage.getInstance("otsoe.jpg");
            image.setImageMask(mask);
            image.setAbsolutePosition(60, 550);
            // explicit masking
            cb.addImage(image);
            // stencil masking
            cb.setRGBColorFill(255, 0, 0);
            cb.addImage(mask, mask.getScaledWidth() * 8, 0, 0, mask.getScaledHeight() * 8, 100, 450);
View Full Code Here

            // step 3: we open the document
            document.open();
           
            // step 4:
            document.add(new Paragraph("1st image"));
            LwgImage jpg = LwgImage.getInstance("otsoe.jpg");
            document.add(jpg);
            document.add(new Paragraph("2nd image"));
            LwgImage gif= LwgImage.getInstance("getacro.gif");
            document.add(gif);
            document.add(new Paragraph("3rd image"));
            document.add(jpg);
            document.add(new Paragraph("4th image"));
            document.add(gif);
View Full Code Here

            stamp.setMoreInfo(moreInfo);
            // adding content to each page
            int i = 0;
            PdfContentByte under;
            PdfContentByte over;
            LwgImage img = LwgImage.getInstance("watermark.jpg");
            BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED);
            img.setAbsolutePosition(200, 400);
            while (i < n) {
              i++;
              // watermark under the existing page
              under = stamp.getUnderContent(i);
              under.addImage(img);
View Full Code Here

    private float firstLineRealHeight() {
        float firstLineRealHeight = 0f;
        if (firstLine != null) {
            PdfChunk chunk = firstLine.getChunk(0);
            if (chunk != null) {
                LwgImage image = chunk.getImage();
                if (image != null) {
                    firstLineRealHeight = firstLine.getChunk(0).getImage().getScaledHeight();
                } else {
                    firstLineRealHeight = useAscender ? firstLine.getAscender() : leading;
                }
View Full Code Here

     * @param alignment   horizontal alignment (constant from Element class)
     * @return the height of the image
     */

    private float addImage(LwgImage i, float left, float right, float extraHeight, int alignment) {
        LwgImage image = LwgImage.getInstance(i);
        if (image.getScaledWidth() > right - left) {
            image.scaleToFit(right - left, Float.MAX_VALUE);
        }
        flushCurrentLine();
        if (line == null) {
            line = new PdfLine(left, right, alignment, leading);
        }
        PdfLine imageLine = line;

        // left and right in chunk is relative to the start of the line
        right = right - left;
        left = 0f;

        if ((image.getAlignment() & LwgImage.RIGHT) == LwgImage.RIGHT) {
            left = right - image.getScaledWidth();
        } else if ((image.getAlignment() & LwgImage.MIDDLE) == LwgImage.MIDDLE) {
            left = left + ((right - left - image.getScaledWidth()) / 2f);
        }
        Chunk imageChunk = new Chunk(image, left, 0);
        imageLine.add(new PdfChunk(imageChunk, null));
        addLine(imageLine);
        return imageLine.height();
View Full Code Here

                    difference += line.height();
                }
            }
        }
        if (difference > 0) {
            LwgImage image;
            for (Iterator i = images.iterator(); i.hasNext();) {
                image = (LwgImage) i.next();
                image.setAbsolutePosition(image.getAbsoluteX(), image.getAbsoluteY() - difference - leading);
            }
        }
        return result;
    }
View Full Code Here

        if (getTop() < bottom) {
            return new ArrayList();
        }
        top = Math.min(getTop(), top);
        // initializations
        LwgImage image;
        float height;
        ArrayList result = new ArrayList();
        // we loop over the images
        for (Iterator i = images.iterator(); i.hasNext() && !header;) {
            image = (LwgImage) i.next();
            height = image.getAbsoluteY();
            // if the currentPosition is higher than the bottom, we add the line to the result
            if (top - height > (bottom + cellpadding)) {
                image.setAbsolutePosition(image.getAbsoluteX(), top - height);
                result.add(image);
                i.remove();
            }
        }
        return result;
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.