Package com.lowagie.text

Examples of com.lowagie.text.Image


                    content.append("\nEI\nQ").append_i(separator);
                }
                else {
                    PdfName name;
                    PageResources prs = getPageResources();
                    Image maskImage = image.getImageMask();
                    if (maskImage != null) {
                        name = writer.addDirectImageSimple(maskImage);
                        prs.addXObject(name, writer.getImageReference(name));
                    }
                    name = writer.addDirectImageSimple(image);
View Full Code Here


     */   
    public static Image getImage(URL url) throws IOException {
        InputStream is = null;
        try {
            is = url.openStream();
            Image img = getImage(is);
            img.setUrl(url);
            return img;
        }
        finally {
            if (is != null) {
                is.close();
View Full Code Here

     * @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

    maxHeight = 0;
    for (int k = 0; k < cells.length; ++k) {
      PdfPCell cell = cells[k];
      if (cell == null)
        continue;
      Image img = cell.getImage();
      if (img != null) {
        img.scalePercent(100);
                float refWidth = img.getScaledWidth();
                if (cell.getRotation() == 90 || cell.getRotation() == 270) {
                    refWidth = img.getScaledHeight();
                }
                float scale = (cell.getRight() - cell.getEffectivePaddingRight()
                    - cell.getEffectivePaddingLeft() - cell.getLeft())
                    / refWidth;
                img.scalePercent(scale * 100);
                float refHeight = img.getScaledHeight();
                if (cell.getRotation() == 90 || cell.getRotation() == 270) {
                    refHeight = img.getScaledWidth();
                }
                cell.setBottom(cell.getTop() - cell.getEffectivePaddingTop()
                    - cell.getEffectivePaddingBottom()
                    - refHeight);
      } else {
View Full Code Here

    for (int k = newStart; k < colEnd; ++k) {
      PdfPCell cell = cells[k];
      if (cell == null)
        continue;
      writeBorderAndBackground(xPos, yPos, cell, canvases);
      Image img = cell.getImage();
      float tly = 0;
      switch (cell.getVerticalAlignment()) {
      case Element.ALIGN_BOTTOM:
        tly = cell.getTop() + yPos - maxHeight + cell.getHeight()
            - cell.getEffectivePaddingTop();
        break;
      case Element.ALIGN_MIDDLE:
        tly = cell.getTop() + yPos + (cell.getHeight() - maxHeight) / 2
            - cell.getEffectivePaddingTop();
        break;
      default:
        tly = cell.getTop() + yPos - cell.getEffectivePaddingTop();
        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() > maxHeight) {
          img.scalePercent(100);
          float scale = (maxHeight - 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

      PdfPCell cell = cells[k];
      if (cell == null)
        continue;
      fh[k * 2] = cell.getFixedHeight();
      fh[k * 2 + 1] = cell.getMinimumHeight();
      Image img = cell.getImage();
      PdfPCell c2 = new PdfPCell(cell);
      if (img != null) {
        if (newHeight > cell.getEffectivePaddingBottom()
            + cell.getEffectivePaddingTop() + 2) {
          c2.setPhrase(null);
View Full Code Here

            else if (render == SignatureRenderGraphicAndDescription) {
                ColumnText ct2 = new ColumnText(t);
                ct2.setRunDirection(runDirection);
                ct2.setSimpleColumn(signatureRect.getLeft(), signatureRect.getBottom(), signatureRect.getRight(), signatureRect.getTop(), 0, Element.ALIGN_RIGHT);

                Image im = Image.getInstance(signatureGraphic);
                im.scaleToFit(signatureRect.getWidth(), signatureRect.getHeight());

                Paragraph p = new Paragraph();
                // must calculate the point to draw from to make image appear in middle of column
                float x = 0;
                // experimentation found this magic number to counteract Adobe's signature graphic, which
                // offsets the y co-ordinate by 15 units
                float y = -im.getScaledHeight() + 15;

                x = x + (signatureRect.getWidth() - im.getScaledWidth()) / 2;
                y = y - (signatureRect.getHeight() - im.getScaledHeight()) / 2;
                p.add(new Chunk(im, x + (signatureRect.getWidth() - im.getScaledWidth()) / 2, y, false));
                ct2.addElement(p);
                ct2.go();
            }
           
            if (size <= 0) {
View Full Code Here

      if (tag.equals(HtmlTags.IMAGE)) {
        String src = (String) h.get(ElementTags.SRC);
        if (src == null)
          return;
        cprops.addToChain(tag, h);
        Image img = null;
        if (interfaceProps != null) {
          ImageProvider ip = (ImageProvider) interfaceProps
              .get("img_provider");
          if (ip != null)
            img = ip.getImage(src, h, cprops, document);
          if (img == null) {
            HashMap images = (HashMap) interfaceProps
                .get("img_static");
            if (images != null) {
              Image tim = (Image) images.get(src);
              if (tim != null)
                img = Image.getInstance(tim);
            } else {
              if (!src.startsWith("http")) { // relative src references only
                String baseurl = (String) interfaceProps
View Full Code Here

   
    public void drawImage(FSImage fsImage, int x, int y) {
        if (fsImage instanceof PDFAsImage) {
            drawPDFAsImage((PDFAsImage)fsImage, x, y);
        } else {
            Image image = ((ITextFSImage)fsImage).getImage();
           
            if (fsImage.getHeight() <= 0 || fsImage.getWidth() <= 0) {
                return;
            }
           
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.