Package com.lowagie.text

Examples of com.lowagie.text.Image


            cb.lineTo(370, 525);
            cb.moveTo(410, 525);
            cb.lineTo(410, 0);
            cb.stroke();
            if (getValue("front") != null) {
              Image front = (Image)getValue("front");
              front.scaleToFit(370, 525);
              front.setAbsolutePosition(410f + (370f - front.scaledWidth()) / 2f, (525f - front.scaledHeight()) / 2f);
              document.add(front);
            }
            if (getValue("back") != null) {
              Image back = (Image)getValue("back");
              back.scaleToFit(370, 525);
              back.setAbsolutePosition((370f - back.scaledWidth()) / 2f, (525f - back.scaledHeight()) / 2f);
              document.add(back);
            }
            if (getValue("side") != null) {
              Image side = (Image)getValue("side");
              side.scaleToFit(40, 525);
              side.setAbsolutePosition(370 + (40f - side.scaledWidth()) / 2f, (525f - side.scaledHeight()) / 2f);
              document.add(side);
            }

            // step 5: we close the document
            document.close();
View Full Code Here


      boolean adjustSize = false;
      Document document = new Document(PageSize.A4);
            float width = PageSize.A4.width() - 40;
            float height = PageSize.A4.height() - 120;
      if ("ORIGINAL".equals(getValue("pagesize"))) {
        Image img = TiffImage.getTiffImage(ra, 1);
                if (img.getDpiX() > 0 && img.getDpiY() > 0) {
                    img.scalePercent(7200f / img.getDpiX(), 7200f / img.getDpiY());
                }
        document.setPageSize(new Rectangle(img.scaledWidth(), img.scaledHeight()));
        adjustSize = true;
      }
      else if ("LETTER".equals(getValue("pagesize"))) {
        document.setPageSize(PageSize.LETTER);
                width = PageSize.LETTER.width() - 40;
                height = PageSize.LETTER.height() - 120;
      }
      PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(pdf_file));
      document.open();
      PdfContentByte cb = writer.getDirectContent();
            for (int c = 0; c < comps; ++c) {
                Image img = TiffImage.getTiffImage(ra, c + 1);
                if (img != null) {
                    if (img.getDpiX() > 0 && img.getDpiY() > 0) {
                        img.scalePercent(7200f / img.getDpiX(), 7200f / img.getDpiY());
                    }
                  if (adjustSize) {
              document.setPageSize(new Rectangle(img.scaledWidth(),
                  img.scaledHeight()));
                        document.newPage();
                    img.setAbsolutePosition(0, 0);
                  }
                  else {
                    if (img.scaledWidth() > width || img.scaledHeight() > height) {
                            if (img.getDpiX() > 0 && img.getDpiY() > 0) {
                                float adjx = width / img.scaledWidth();
                                float adjy = height / img.scaledHeight();
                                float adj = Math.min(adjx, adjy);
                                img.scalePercent(7200f / img.getDpiX() * adj, 7200f / img.getDpiY() * adj);
                            }
                            else
                                img.scaleToFit(width, height);
                    }
                    img.setAbsolutePosition(20, 20);
                        document.newPage();
                        document.add(new Paragraph(tiff_file + " - page " + (c + 1)));
                  }
                    cb.addImage(img);
                    System.out.println("Finished page " + (c + 1));
View Full Code Here

      String label;
            for (Iterator i = images.iterator(); i.hasNext(); ) {
              image = (File) i.next();
              System.out.println("Testing image: " + image.getName());
              try {
                Image img = Image.getInstance(image.getAbsolutePath());
                dpiX=img.getDpiX();
                    if (dpiX == 0) dpiX=72;
                    dpiY=img.getDpiY();
                    if (dpiY == 0) dpiY=72;
                    imgWidthPica=(72*img.plainWidth()) / dpiX;
                    imgHeightPica=(72*img.plainHeight()) / dpiY;
                    img.scaleAbsolute(imgWidthPica,imgHeightPica);
                    document.setPageSize(new Rectangle(imgWidthPica, imgHeightPica));
                  if (document.isOpen()) {
                    document.newPage();
                  }
                  else {
                    document.open();
                  }
                  img.setAbsolutePosition(0, 0);
                    document.add(img);
                    label = image.getName();
                    if (label.lastIndexOf('.') > 0)
                      label = label.substring(0, label.lastIndexOf('.'));
                    pageLabels.addPageLabel(writer.getPageNumber(), PdfPageLabels.EMPTY, label);
View Full Code Here

                cb.stroke();

                ClassLoader classLoader = ConversationUtils.class.getClassLoader();
                Enumeration<URL> providerEnum = classLoader.getResources("images/pdf_generatedbyof.gif");
                while (providerEnum.hasMoreElements()) {
                    Image gif = Image.getInstance(providerEnum.nextElement());
                    cb.addImage(gif, 221, 0, 0, 28, (int)document.leftMargin(),
                        (int)document.bottomMargin() - 35);
                }

            }
View Full Code Here

                cb.setLineWidth(2);
                cb.moveTo(document.leftMargin(), document.bottomMargin() + 32);
                cb.lineTo(document.getPageSize().width() - document.rightMargin(), document.bottomMargin() + 32);
                cb.stroke();

                Image gif = Image.getInstance("http://" + request.getServerName() +
                    ":" + request.getServerPort() + "/plugins/monitoring/images/pdf_generatedbyof.gif");
                cb.addImage(gif, 221, 0, 0, 28, (int)document.leftMargin(), (int)document.bottomMargin());

            } catch (Exception e) {
                Log.error("error drawing PDF footer: " + e.getMessage());
View Full Code Here

        document.setMargins(40, 40, 30, 30);
        document.setPageSize(PageSize.A4.rotate());
        document.newPage();

        if (image != null) {
            Image img = Image.getInstance(image, null);
            img.setAlignment(Element.ALIGN_CENTER);
            document.add(img);
        }


        document.setMargins(40,40,170,60);
View Full Code Here

    }

    @Override
    public Element render() {
        try {
            Image image = Image.getInstance(properties.getFile().getFile());
            return image;
        } catch (BadElementException ex) {
            Logger.getLogger(PdfFormBuilderImage.class.getName()).log(Level.SEVERE, null, ex);
        } catch (MalformedURLException ex) {
            Logger.getLogger(PdfFormBuilderImage.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here

    public void writeImage(float x, float y, BufferedImage image, float width,
            float height) throws IOException {
        checkIfDocIsClosed();

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

    public void writeImage(float x, float y, BufferedImage image, float width,
            float height) throws IOException {
        checkIfDocIsClosed();

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

  public void writeImage(final float x, final float y, final BufferedImage image, final float width,
      final float height) throws IOException {
    checkIfDocIsClosed();

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

TOP

Related Classes of com.lowagie.text.Image

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.