Package com.itextpdf.text

Examples of com.itextpdf.text.Image


    addEmptyLine(oneEmptyLine, 1);
    /**
     * Add the logo
     */
    try {
      Image image = Image.getInstance(pathFile.get("util")
          + (osName.toLowerCase().startsWith("linux") ? "/logo.png" : "\\logo.png"));
      image.setAlignment(Element.ALIGN_LEFT);
      document.add(image);
    } catch (MalformedURLException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
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()) {
                        Image image = chunk.getImage();
                        float matrix[] = image.matrix();
                        matrix[Image.CX] = xMarker + chunk.getImageOffsetX() - matrix[Image.CX];
                        matrix[Image.CY] = yMarker + chunk.getImageOffsetY() - matrix[Image.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

        }
        boolean skipZero = decodeImageData();   // decode pixel data
        if (!skipZero)
            skip();

        Image img = null;
        try {
            img = new ImgRaw(iw, ih, 1, m_bpc, m_out);
            PdfArray colorspace = new PdfArray();
            colorspace.add(PdfName.INDEXED);
            colorspace.add(PdfName.DEVICERGB);
            int len = m_curr_table.length;
            colorspace.add(new PdfNumber(len / 3 - 1));
            colorspace.add(new PdfString(m_curr_table));
            PdfDictionary ad = new PdfDictionary();
            ad.put(PdfName.COLORSPACE, colorspace);
            img.setAdditional(ad);
            if (transparency) {
                img.setTransparency(new int[]{transIndex, transIndex});
            }
        }
        catch (Exception e) {
            throw new ExceptionConverter(e);
        }
        img.setOriginalType(Image.ORIGINAL_GIF);
        img.setOriginalData(fromData);
        img.setUrl(fromUrl);
        GifFrame gf = new GifFrame();
        gf.image = img;
        gf.ix = ix;
        gf.iy = iy;
        frames.add(gf);   // add image to frame list
View Full Code Here

   
    try {
      JBIG2SegmentReader sr = new JBIG2SegmentReader(ra);
      sr.read();
      JBIG2SegmentReader.JBIG2Page p = sr.getPage(page);
      Image img = new ImgJBIG2(p.pageBitmapWidth, p.pageBitmapHeight, p.getData(true), sr.getGlobal(true));
      return img;
    } catch (Exception e) {
          throw new ExceptionConverter(e);
      }
  }
View Full Code Here

                    byte b[] = new byte[tsize * 2 - (in.getLength() - lenMarker)];
                    for (int k = 0; k < b.length; ++k)
                        b[k] = (byte)in.readByte();
                    try {
                        ByteArrayInputStream inb = new ByteArrayInputStream(b);
                        Image bmp = BmpImage.getImage(inb, true, b.length);
                        cb.saveState();
                        cb.rectangle(xDest, yDest, destWidth, destHeight);
                        cb.clip();
                        cb.newPath();
                        bmp.scaleAbsolute(destWidth * bmp.getWidth() / srcWidth, -destHeight * bmp.getHeight() / srcHeight);
                        bmp.setAbsolutePosition(xDest - destWidth * xSrc / srcWidth, yDest + destHeight * ySrc / srcHeight - bmp.getScaledHeight());
                        cb.addImage(bmp);
                        cb.restoreState();
                    }
                    catch (Exception e) {
                        // empty on purpose
View Full Code Here

                    PdfName rname = new PdfName("img" + images.size());
                    images.put(image.getMySerialId(), rname);
                    imageDictionary.put(rname, dref);
                    return rname;
                }
                Image maskImage = image.getImageMask();
                PdfIndirectReference maskRef = null;
                if (maskImage != null) {
                    PdfName mname = images.get(maskImage.getMySerialId());
                    maskRef = getImageReference(mname);
                }
                PdfImage i = new PdfImage(image, "img" + images.size(), maskRef);
                if (image instanceof ImgJBIG2) {
                    byte[] globals = ((ImgJBIG2) image).getGlobalBytes();
View Full Code Here

        continue;
      float currentMaxHeight = maxHeight + extraHeights[k];
     
      writeBorderAndBackground(xPos, yPos, currentMaxHeight, cell, canvases);

      Image img = cell.getImage();
     
      float tly = cell.getTop() + yPos - cell.getEffectivePaddingTop();
      if (cell.getHeight() <= currentMaxHeight) {
        switch (cell.getVerticalAlignment()) {
        case Element.ALIGN_BOTTOM:
          tly = cell.getTop() + yPos - currentMaxHeight + cell.getHeight()
              - cell.getEffectivePaddingTop();
          break;
        case Element.ALIGN_MIDDLE:
          tly = cell.getTop() + yPos + (cell.getHeight() - currentMaxHeight) / 2
              - cell.getEffectivePaddingTop();
          break;
        default:
          break;
        }
      }
      if (img != null) {
                if (cell.getRotation() != 0) {
                    img = Image.getInstance(img);
                    img.setRotation(img.getImageRotation() + (float)(cell.getRotation() * Math.PI / 180.0));
                }
        boolean vf = false;
        if (cell.getHeight() > currentMaxHeight) {
          img.scalePercent(100);
          float scale = (currentMaxHeight - cell.getEffectivePaddingTop() - cell
              .getEffectivePaddingBottom())
              / img.getScaledHeight();
          img.scalePercent(scale * 100);
          vf = true;
        }
        float left = cell.getLeft() + xPos
            + cell.getEffectivePaddingLeft();
        if (vf) {
          switch (cell.getHorizontalAlignment()) {
          case Element.ALIGN_CENTER:
            left = xPos
                + (cell.getLeft() + cell.getEffectivePaddingLeft()
                    + cell.getRight()
                    - cell.getEffectivePaddingRight() - img
                    .getScaledWidth()) / 2;
            break;
          case Element.ALIGN_RIGHT:
            left = xPos + cell.getRight()
                - cell.getEffectivePaddingRight()
                - img.getScaledWidth();
            break;
          default:
            break;
          }
          tly = cell.getTop() + yPos - cell.getEffectivePaddingTop();
        }
        img.setAbsolutePosition(left, tly - img.getScaledHeight());
        try {
          canvases[PdfPTable.TEXTCANVAS].addImage(img);
        } catch (DocumentException e) {
          throw new ExceptionConverter(e);
        }
View Full Code Here

        }
        continue;
      }
      fixHs[k] = cell.getFixedHeight();
      minHs[k] = cell.getMinimumHeight();
      Image img = cell.getImage();
      PdfPCell newCell = new PdfPCell(cell);
      if (img != null) {
        if (newHeight > cell.getEffectivePaddingBottom() + cell.getEffectivePaddingTop() + 2) {
          newCell.setPhrase(null);
          allEmpty = false;
View Full Code Here

   * @return  the height of the cell
   * @since  3.0.0
   */
  public float getMaxHeight() {
    boolean pivoted = getRotation() == 90 || getRotation() == 270;
    Image img = getImage();
    if (img != null) {
      img.scalePercent(100);
      float refWidth = pivoted ? img.getScaledHeight() : img.getScaledWidth();
      float scale = (getRight() - getEffectivePaddingRight()
                    - getEffectivePaddingLeft() - getLeft()) / refWidth;
      img.scalePercent(scale * 100);
      float refHeight = pivoted ? img.getScaledWidth() : img.getScaledHeight();
      setBottom(getTop() - getEffectivePaddingTop() - getEffectivePaddingBottom() - refHeight);
    }
    else {
      if (pivoted && hasFixedHeight())
        setBottom(getTop() - getFixedHeight());
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"));
    Image image = Image.getInstance(value);

    value = attributes.getProperty(ElementTags.ALIGN);
    int align = 0;
    if (value != null) {
      if (ElementTags.ALIGN_LEFT.equalsIgnoreCase(value))
        align |= Image.LEFT;
      else if (ElementTags.ALIGN_RIGHT.equalsIgnoreCase(value))
        align |= Image.RIGHT;
      else if (ElementTags.ALIGN_MIDDLE.equalsIgnoreCase(value))
        align |= Image.MIDDLE;
    }
    if ("true".equalsIgnoreCase(attributes
        .getProperty(ElementTags.UNDERLYING)))
      align |= Image.UNDERLYING;
    if ("true".equalsIgnoreCase(attributes
        .getProperty(ElementTags.TEXTWRAP)))
      align |= Image.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

TOP

Related Classes of com.itextpdf.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.