Package com.lowagie.text

Examples of com.lowagie.text.Image


     */   
    public void addElement(Element element) {
        if (element == null)
            return;
        if (element instanceof Image) {
            Image img = (Image)element;
            PdfPTable t = new PdfPTable(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 Image.LEFT:
                    t.setHorizontalAlignment(Element.ALIGN_LEFT);
                    break;
                case Image.RIGHT:
                    t.setHorizontalAlignment(Element.ALIGN_RIGHT);
                    break;
                default:
                    t.setHorizontalAlignment(Element.ALIGN_CENTER);
                    break;
            }
            PdfPCell c = new PdfPCell(img, true);
            c.setPadding(0);
            c.setBorder(img.getBorder());
            c.setBorderColor(img.getBorderColor());
            c.setBorderWidth(img.getBorderWidth());
            c.setBackgroundColor(img.getBackgroundColor());
            t.addCell(c);
            element = t;
        }
        if (element.type() == Element.CHUNK) {
          element = new Paragraph((Chunk)element);
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

    {
      final RenderableReplacedContent rpc = node.getContent();
      final Object rawObject = rpc.getRawObject();
      if (rawObject instanceof ImageContainer)
      {
        final Image image = imageCache.getImage((ImageContainer) rawObject);
        if (image == null)
        {
          return;
        }
        final StyleContext currentContext = getCurrentContext();
        if (getTextLength() > 0)
        {
          currentContext.add(getText());
          clearText();
        }
        currentContext.add(image);
      }
      else if (rawObject instanceof DrawableWrapper)
      {
        final StrictBounds rect = new StrictBounds
            (node.getX(), node.getY(), node.getWidth(), node.getHeight());
        final ImageContainer ic =
            RenderUtility.createImageFromDrawable((DrawableWrapper) rawObject, rect, node, metaData);
        if (ic == null)
        {
          return;
        }
        final Image image = imageCache.getImage(ic);
        if (image == null)
        {
          return;
        }
View Full Code Here

            - (int)normalHeight
            - yoffset
          );
        pdfContentByte.restoreState();

        Image image = getPxImage();
        image.scaleAbsolute(availableImageWidth, availableImageHeight);
        chunk = new Chunk(image, 0, 0);
      }

      /*
      image.setAbsolutePosition(
 
View Full Code Here

    }
    float baseWidth = iconRect.getWidth() / 10;
    // draw symbol
    switch (layerType) {
      case RASTER:
        Image img = context.getImage("/images/layer-raster.png");
        context.drawImage(img, iconRect, null);
        break;
      case POINT:
      case MULTIPOINT:
        SymbolInfo symbol = styleInfo.getSymbol();
        if (symbol.getImage() != null) {
          try {
            Image pointImage = Image.getInstance(symbol.getImage().getHref());
            context.drawImage(pointImage, iconRect, iconRect);
          } catch (Exception ex) {
            log.error("Not able to create image for POINT Symbol", ex);
          }
        } else if (symbol.getRect() != null) {
View Full Code Here

  }

  private void drawPoint(Coordinate coord, SymbolInfo symbol) {
    if (symbol.getImage() != null) {
      try {
        Image pointImage = Image.getInstance(symbol.getImage().getHref());
        //template.addImage(image, width, 0, 0, height, x, y)
        template.addImage(pointImage, symbol.getImage().getWidth(), 0, 0, symbol.getImage().getHeight()
            , origX + (float) coord.x, origY + (float) coord.y);
      } catch (Exception ex) {
        log.error("Not able to create POINT image for rendering", ex);
View Full Code Here

//          writer.addDirectImageSimple(image);
//     
     
      doc.open();
       PdfPTable headerTable= new PdfPTable(2);
          Image ii = Image.getInstance("c:/smi-logo.gif");
          ii.setAlignment(Element.ALIGN_RIGHT);
          ii.scalePercent(25);
      
          PdfPCell cell1 = new PdfPCell(ii,false);
          cell1.setBorder(0);
         
          headerTable.addCell(cell1);
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

        float width = 0;
        float height = 0;
        try
        {
            Image image = Image.getInstance( new URL( urlName ) );
            image.scaleToFit( ITextUtil.getDefaultPageSize().width() / 2, ITextUtil.getDefaultPageSize().height() / 2 );
            width = image.plainWidth();
            height = image.plainHeight();
        }
        catch ( BadElementException e )
        {
            getLog().error( "BadElementException: " + e.getMessage(), e );
        }
View Full Code Here

    {
      final RenderableReplacedContent rpc = node.getContent();
      final Object rawObject = rpc.getRawObject();
      if (rawObject instanceof ImageContainer)
      {
        final Image image = imageCache.getImage((ImageContainer) rawObject);
        if (image == null)
        {
          return;
        }
        final StyleContext currentContext = getCurrentContext();
        if (getTextLength() > 0)
        {
          currentContext.add(getText());
          clearText();
        }

        image.scaleToFit(targetWidth, targetHeight);
        currentContext.add(image);
      }
      else if (rawObject instanceof DrawableWrapper)
      {
        final StrictBounds rect = new StrictBounds
            (node.getX(), node.getY(), node.getWidth(), node.getHeight());
        final ImageContainer ic =
            RenderUtility.createImageFromDrawable((DrawableWrapper) rawObject, rect, node, metaData);
        if (ic == null)
        {
          return;
        }
        final Image image = imageCache.getImage(ic);
        if (image == null)
        {
          return;
        }

        final StyleContext currentContext = getCurrentContext();
        if (getTextLength() > 0)
        {
          currentContext.add(getText());
          clearText();
        }
        image.scaleToFit(targetWidth, targetHeight);
        currentContext.add(image);
      }
    }
    catch (DocumentException ioe)
    {
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.