Package com.itextpdf.text

Examples of com.itextpdf.text.Image


     * @throws IOException on error
     * @return the image
     */   
    public static Image getImage(byte data[]) throws IOException {
        ByteArrayInputStream is = new ByteArrayInputStream(data);
        Image img = getImage(is);
        img.setOriginalData(data);
        return img;
    }
View Full Code Here


            if ((colorType & 4) != 0)
                --components;
            int bpc = bitDepth;
            if (bpc == 16)
                bpc = 8;
            Image img;
            if (image != null) {
                if (colorType == 3)
                    img = new ImgRaw(width, height, components, bpc, image);
                else
                    img = Image.getInstance(width, height, components, bpc, image);
            }
            else {
                img = new ImgRaw(width, height, components, bpc, idat.toByteArray());
                img.setDeflated(true);
                PdfDictionary decodeparms = new PdfDictionary();
                decodeparms.put(PdfName.BITSPERCOMPONENT, new PdfNumber(bitDepth));
                decodeparms.put(PdfName.PREDICTOR, new PdfNumber(15));
                decodeparms.put(PdfName.COLUMNS, new PdfNumber(width));
                decodeparms.put(PdfName.COLORS, new PdfNumber((colorType == 3 || (colorType & 2) == 0) ? 1 : 3));
                additional.put(PdfName.DECODEPARMS, decodeparms);
            }
            if (additional.get(PdfName.COLORSPACE) == null)
                additional.put(PdfName.COLORSPACE, getColorspace());
            if (intent != null)
                additional.put(PdfName.INTENT, intent);
            if (additional.size() > 0)
                img.setAdditional(additional);
            if (icc_profile != null)
                img.tagICC(icc_profile);
            if (palShades) {
                Image im2 = Image.getInstance(width, height, 1, 8, smask);
                im2.makeMask();
                img.setImageMask(im2);
            }
            if (genBWMask) {
                Image im2 = Image.getInstance(width, height, 1, 1, smask);
                im2.makeMask();
                img.setImageMask(im2);
            }
            img.setDpi(dpiX, dpiY);
            img.setXYRatio(XYRatio);
            img.setOriginalType(Image.ORIGINAL_PNG);
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

   */
  public Image createImage(final Map<String, String> attrs) throws DocumentException, IOException {
    String src = attrs.get(HtmlTags.SRC);
    if (src == null)
      return null;
    Image img = factory.createImage(
        src, attrs, chain, document,
        (ImageProvider)providers.get(IMG_PROVIDER),
        (ImageStore)providers.get(IMG_STORE),
        (String)providers.get(IMG_BASEURL));
    return img;
View Full Code Here

        return overflow;
    }

    private void addToLine(PdfChunk chunk) {
        if (chunk.changeLeading && chunk.isImage()) {
          Image img = chunk.getImage();
          float f = img.getScaledHeight() + chunk.getImageOffsetY()
            + img.getBorderWidthTop() + img.getSpacingBefore();
          if (f > height) height = f;
        }
      line.add(chunk);
    }
View Full Code Here

            chunk = line.get(k);
            if (!chunk.isImage()) {
                normal_leading = Math.max(chunk.font().size(), normal_leading);
            }
            else {
              Image img = chunk.getImage();
              if (chunk.changeLeading()) {
                float height = img.getScaledHeight() + chunk.getImageOffsetY() + img.getSpacingBefore();
                image_leading = Math.max(height, image_leading);
              }
            }
        }
        return new float[]{normal_leading, image_leading};
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

                    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

                    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

    /**
     * Add the logo
     */
    try {
      Image image = Image.getInstance(pathFile.get("util")
          + (osName.toLowerCase().startsWith("linux") ? "/logo.png" : "\\logo.png"));
      image.setAlignment(Element.ALIGN_LEFT);
      image.setWidthPercentage(50);
      document.add(image);
    } catch (MalformedURLException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
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.