Package com.itextpdf.text

Examples of com.itextpdf.text.Image


        boolean splitChar = false;
        boolean surrogate = false;
        for (; currentChar < totalTextLength; ++currentChar) {
            ck = detailChunks[currentChar];
            if (ck.isImage() && minY < yLine) {
                Image img = ck.getImage();
                if (img.isScaleToFitLineWhenOverflow() && yLine + 2 * descender - img.getScaledHeight() - ck.getImageOffsetY() - img.getSpacingBefore() < minY) {
                    float scalePercent = (yLine + 2 * descender - ck.getImageOffsetY() - img.getSpacingBefore() - minY) / img.getHeight() * 100;
                img.scalePercent(scalePercent);
                }
            }
            surrogate = Utilities.isSurrogatePair(text, currentChar);
            if (surrogate)
                uniC = ck.getUnicodeEquivalent(Utilities.convertToUtf32(text, currentChar));
            else
                uniC = ck.getUnicodeEquivalent(text[currentChar]);
            if (PdfChunk.noPrint(uniC))
                continue;
            if (surrogate)
                charWidth = ck.getCharWidth(uniC);
            else
                charWidth = ck.getCharWidth(text[currentChar]);
            splitChar = ck.isExtSplitCharacter(oldCurrentChar, currentChar, totalTextLength, text, detailChunks);
            if (splitChar && Character.isWhitespace((char)uniC))
                lastSplit = currentChar;
            if (width - charWidth < 0) {
              // If the chunk is an image and it is the first one in line, check if resize requested
              // If so, resize to fit the current line width
              if (lastValidChunk == null && ck.isImage()) {
                Image img = ck.getImage();
                if (img.isScaleToFitLineWhenOverflow()) {
                  float scalePercent = width / img.getWidth() * 100;
                  img.scalePercent(scalePercent);
                  charWidth = width;
                }
              }
            }
            if (width - charWidth < 0)
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

            int flags = 0;
            if (ff != null)
                flags = ff.intValue();
            if ((flags & PdfFormField.FF_PUSHBUTTON) != 0) {
                //we'll assume that the value is an image in base64
                Image img;
                try {
                    img = Image.getInstance(Base64.decode(value));
                }
                catch (Exception e) {
                    return false;
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) {
          if (!img.isScaleToFitLineWhenOverflow()) {
            continue;
          }
          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

   * @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()) || getColumn() == null)
        setBottom(getTop() - getFixedHeight());
View Full Code Here

            R, G, B, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            R, G, B, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        };

        Image img = null;
        try {
            img = Image.getInstance(5, 5, 3, 8, data, transparency);
        } catch (BadElementException ex) {
            Log.error(ex.getMessage());
        }
View Full Code Here

    private Image image;

    protected final void init(Stylesheet stylesheet, Rectangle pageSize) throws IOException, BadElementException {
        String imagePath = stylesheet.getPageStyle().backgroundImage;
        float dpi = stylesheet.getGeneralSettings().imageDpi;
        Image img = Image.getInstance(Utilities.getValidatedFileName(imagePath));
        Utilities.rescaleImage(img, 1.0f, 0, 0, pageSize, dpi);
        this.image = img;
    }
View Full Code Here

        float templateWidth = doc.getPageSize().getWidth();
        float templateHight = doc.getPageSize().getHeight();
        PdfTemplate tp = PdfTemplate.createTemplate(writer, templateWidth, templateHight);
        float leftMargin = (doc.isMarginMirroring() && oddOrEven == EVEN) ? doc.rightMargin() : doc.leftMargin();
        table.writeSelectedRows(0, -1, leftMargin, templateHight, tp);
        Image footer = Image.getInstance(tp);
        footer.setAbsolutePosition(0, 0);
        this.image = footer;
    }
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) {
        float padding = cell.getEffectivePaddingBottom() + cell.getEffectivePaddingTop() + 2;
        if ((img.isScaleToFitLineWhenOverflow() || img.getScaledHeight() + padding < newHeight)
            && newHeight > padding) {
          newCell.setPhrase(null);
          allEmpty = false;
        }
      }
View Full Code Here

      final ChainedProperties chain,
      final DocListener document,
      final ImageProvider img_provider,
      final HashMap<String, Image> img_store,
      final String img_baseurl) throws DocumentException, IOException {
    Image img = null;
    // getting the image using an image provider
    if (img_provider != null)
      img = img_provider.getImage(src, attrs, chain, document);
    // getting the image from an image store
    if (img == null && img_store != null) {
      Image tim = img_store.get(src);
      if (tim != null)
        img = Image.getInstance(tim);
    }
    if (img != null)
      return img;
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.