Package com.lowagie.text

Examples of com.lowagie.text.Image


          }
        }

        // does it have image info?

        Image img = cell.getImage();
        if(img != null) {
            try {
        RtfBasicElement[] rtfElements = this.document.getMapper().mapElement(img);
        for (int i = 0; i < rtfElements.length; i++) {
          rtfElements[i].setInTable(true);
View Full Code Here


      final URLImageContainer urlImageContainer = (URLImageContainer) reference;
      final ResourceKey url = urlImageContainer.getResourceKey();
      if (url != null && urlImageContainer.isLoadable())
      {
        identity = url;
        final Image cached = (Image) cachedImages.get(identity);
        if (cached != null)
        {
          return cached;
        }

        try
        {
          final ResourceData resourceData = resourceManager.load(url);
          final byte[] data = resourceData.getResource(resourceManager);
          final Image itextimage = Image.getInstance(data);
          cachedImages.put(identity, itextimage);
          return itextimage;
        }
        catch (ResourceException re)
        {
          RTFImageCache.logger.info("Caught illegal Image, will recode to PNG instead", re);
        }
        catch (BadElementException be)
        {
          RTFImageCache.logger.info("Caught illegal Image, will recode to PNG instead", be);
        }
        catch (IOException ioe)
        {
          RTFImageCache.logger.info("Unable to read the raw-data, will try to recode image-data.", ioe);
        }

        try
        {
          final Resource resource = resourceManager.create(url, null, Image.class);
          image = (java.awt.Image) resource.getResource();
        }
        catch (ResourceException re)
        {
          RTFImageCache.logger.info("Caught illegal Image, will try to find local instance", re);
        }
      }
    }

    if (reference instanceof LocalImageContainer && image == null)
    {
      final LocalImageContainer localImageContainer =
          (LocalImageContainer) reference;
      image = localImageContainer.getImage();
      if (image != null)
      {
        // check, if the content was cached ...
        identity = localImageContainer.getIdentity();
        if (identity != null)
        {
          final Image cachedImage = (Image) cachedImages.get(identity);
          if (cachedImage != null)
          {
            return cachedImage;
          }
        }

      }
    }
    if (image == null)
    {
      return null;
    }

    final WaitingImageObserver obs = new WaitingImageObserver(image);
    obs.waitImageLoaded();

    try
    {
      final byte[] data = RenderUtility.encodeImage(image);
      final Image itextimage = Image.getInstance(data);
      if (identity != null)
      {
        cachedImages.put(identity, itextimage);
      }
      return itextimage;
View Full Code Here

      }

      if (o instanceof URLImageContainer)
      {
        final URLImageContainer imageContainer = (URLImageContainer) o;
        final Image image = createImage(imageContainer);
        if (image != null)
        {
          return image;
        }
      }
View Full Code Here

    public void onEndPage(PdfWriter writer,
                          Document document) {

        try {
            Image image = Image.getInstance( DroolsDocsBuilder.class.getResource( "drools-guvnor.png" ) );
            image.setAlignment( Image.RIGHT );
            image.scaleAbsolute( 100,
                                 30 );
            Rectangle page = document.getPageSize();
            PdfPTable head = new PdfPTable( 2 );

            PdfPCell cell1 = new PdfPCell( image );
View Full Code Here

       
        try {
           
            //draw the map (at a high resolution as specified above)
            ApplicationGIS.drawMap(drawMapParameter);
            Image img = Image.getInstance(bufferedImage2ByteArray(imageOfRastersOnly));
           
            //scale the image down to fit into the page
            img.scaleAbsolute(mapBoundsInTemplate.width, mapBoundsInTemplate.height);
           
            //set the location of the image
            int left = mapBoundsInTemplate.x;
            int bottom = pageSize.height - mapBoundsInTemplate.height - mapBoundsInTemplate.y;
            img.setAbsolutePosition(left, bottom); //(0,0) is bottom left in the PDF coordinate system
        
            doc.add(img);
            addWhiteMapBorder(img, doc);
           
        }
View Full Code Here

                    borderWidth,
                    BufferedImage.TYPE_INT_RGB);
            Graphics2D g1 = bufferedTop.createGraphics();
            g1.setBackground(color);
            g1.clearRect(0, 0, bufferedTop.getWidth(),bufferedTop.getHeight());
            Image top = Image.getInstance(bufferedImage2ByteArray(bufferedTop));
            top.setAbsolutePosition(img.getAbsoluteX(), img.getAbsoluteY()+img.getScaledHeight()-bufferedTop.getHeight()/2);
           
            BufferedImage bufferedBottom = new BufferedImage((int)img.getScaledWidth(),
                    borderWidth,
                    BufferedImage.TYPE_INT_RGB);
            Graphics2D g2 = bufferedBottom.createGraphics();
            g2.setBackground(color);
            g2.clearRect(0, 0, bufferedBottom.getWidth(),bufferedBottom.getHeight());
            Image bottom = Image.getInstance(bufferedImage2ByteArray(bufferedBottom));
            bottom.setAbsolutePosition(img.getAbsoluteX(), img.getAbsoluteY()-bufferedTop.getHeight()/2);
           
            BufferedImage bufferedLeft = new BufferedImage(borderWidth,
                    (int)img.getScaledHeight(),
                    BufferedImage.TYPE_INT_RGB);
            Graphics2D g3 = bufferedLeft.createGraphics();
            g3.setBackground(color);
            g3.clearRect(0, 0, bufferedLeft.getWidth(),bufferedLeft.getHeight());
            Image left = Image.getInstance(bufferedImage2ByteArray(bufferedLeft));
            left.setAbsolutePosition(img.getAbsoluteX()-bufferedLeft.getWidth()/2, img.getAbsoluteY());
           
            BufferedImage bufferedRight = new BufferedImage(borderWidth,
                    (int)img.getScaledHeight(),
                    BufferedImage.TYPE_INT_RGB);
            Graphics2D g4 = bufferedRight.createGraphics();
            g4.setBackground(color);
            g4.clearRect(0, 0, bufferedRight.getWidth(),bufferedRight.getHeight());
            Image right = Image.getInstance(bufferedImage2ByteArray(bufferedRight));
            right.setAbsolutePosition(img.getAbsoluteX()+img.getScaledWidth()-bufferedRight.getWidth()/2, img.getAbsoluteY());
           
           
            doc.add(top);
            doc.add(bottom);
            doc.add(left);
View Full Code Here

                              JdomElement element, GlobalConfig globalData, String value)
          throws DocumentException {

    Barcode128 barCode = new Barcode128();
    barCode.setCode(value);
    Image image = barCode.createImageWithBarcode(cb, null, null);

    replaceImage(cb, reader, currentPage, element, globalData, image);
  }
View Full Code Here

    template.endText();

    template.setWidth(width);
    template.setHeight(height);

    Image img = Image.getInstance(template);
    img.setRotationDegrees(90);
    img.setAlignment(Element.ALIGN_CENTER);

    return getLine(new Chunk(img, offsetX, offsetY));
  }
View Full Code Here

        sap.setAcro6Layers(true);

        final String tmpImgPath = options.getImgPath();
        if (tmpImgPath != null) {
          options.log("console.createImage", tmpImgPath);
          final Image img = Image.getInstance(tmpImgPath);
          options.log("console.setSignatureGraphic");
          sap.setSignatureGraphic(img);
        }
        final String tmpBgImgPath = options.getBgImgPath();
        if (tmpBgImgPath != null) {
          options.log("console.createImage", tmpBgImgPath);
          final Image img = Image.getInstance(tmpBgImgPath);
          options.log("console.setImage");
          sap.setImage(img);
        }
        options.log("console.setImageScale");
        sap.setImageScale(options.getBgImgScale());
View Full Code Here

      File even_file = (File)getValue("even");
      if (getValue("destfile") == null) throw new InstantiationException("You need to choose a destination file");
      File pdf_file = (File)getValue("destfile");
      RandomAccessFileOrArray odd = new RandomAccessFileOrArray(odd_file.getAbsolutePath());
      RandomAccessFileOrArray even = new RandomAccessFileOrArray(even_file.getAbsolutePath());
      Image img = TiffImage.getTiffImage(odd, 1);
      Document document = new Document(new Rectangle(img.scaledWidth(),
          img.scaledHeight()));
      PdfWriter writer = PdfWriter.getInstance(document,
          new FileOutputStream(pdf_file));
      document.open();
      PdfContentByte cb = writer.getDirectContent();
      int count = Math.max(TiffImage.getNumberOfPages(odd), TiffImage
          .getNumberOfPages(even));
      for (int c = 0; c < count; ++c) {
        try {
          Image imgOdd = TiffImage.getTiffImage(odd, c + 1);
          Image imgEven = TiffImage.getTiffImage(even, count - c);
          document.setPageSize(new Rectangle(imgOdd.scaledWidth(),
              imgOdd.scaledHeight()));
          document.newPage();
          imgOdd.setAbsolutePosition(0, 0);
          cb.addImage(imgOdd);
          document.setPageSize(new Rectangle(imgEven.scaledWidth(),
              imgEven.scaledHeight()));
          document.newPage();
          imgEven.setAbsolutePosition(0, 0);
          cb.addImage(imgEven);

        } catch (Exception e) {
          System.out.println("Exception page " + (c + 1) + " "
              + e.getMessage());
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.