Tabnine Logo
Image.getHeight
Code IndexAdd Tabnine to your IDE (free)

How to use
getHeight
method
in
com.itextpdf.text.Image

Best Java code snippets using com.itextpdf.text.Image.getHeight (Showing top 20 results out of 315)

origin: youseries/ureport

  private com.itextpdf.text.Image buildPdfImage(String base64Data, int width,int height) throws Exception{
    com.itextpdf.text.Image pdfImg=null;
    InputStream input=ImageUtils.base64DataToInputStream(base64Data);
    try{
      byte[] bytes=IOUtils.toByteArray(input);
      pdfImg=com.itextpdf.text.Image.getInstance(bytes);
      float imgWidth=pdfImg.getWidth();
      float imgHeight=pdfImg.getHeight();
      if(width==0){
        width=Float.valueOf(imgWidth).intValue();
      }
      if(height==0){
        height=Float.valueOf(imgHeight).intValue();
      }
      width=UnitUtils.pixelToPoint(width-2);
      height=UnitUtils.pixelToPoint(height-2);
      pdfImg.scaleToFit(width,height);
    }finally{
      IOUtils.closeQuietly(input);
    }
    return pdfImg;
  }
}
origin: org.technbolts/gutenberg

public static void scaleToFit(Image img, Rectangle box) {
  float scaleWidth = box.getWidth() / img.getWidth();
  float scaleHeight = box.getHeight() / img.getHeight();
  float scale = Math.min(scaleHeight, scaleWidth);
  if (scale < 1)
    img.scalePercent(scale * 100f);
}
origin: com.bstek.ureport/ureport2-core

  private com.itextpdf.text.Image buildPdfImage(String base64Data, int width,int height) throws Exception{
    com.itextpdf.text.Image pdfImg=null;
    InputStream input=ImageUtils.base64DataToInputStream(base64Data);
    try{
      byte[] bytes=IOUtils.toByteArray(input);
      pdfImg=com.itextpdf.text.Image.getInstance(bytes);
      float imgWidth=pdfImg.getWidth();
      float imgHeight=pdfImg.getHeight();
      if(width==0){
        width=Float.valueOf(imgWidth).intValue();
      }
      if(height==0){
        height=Float.valueOf(imgHeight).intValue();
      }
      width=UnitUtils.pixelToPoint(width-2);
      height=UnitUtils.pixelToPoint(height-2);
      pdfImg.scaleToFit(width,height);
    }finally{
      IOUtils.closeQuietly(input);
    }
    return pdfImg;
  }
}
origin: com.itextpdf/itextpdf

/**
 * Scale the width and height of an image to a certain percentage.
 *
 * @param percentX
 *            the scaling percentage of the width
 * @param percentY
 *            the scaling percentage of the height
 */
public void scalePercent(final float percentX, final float percentY) {
  plainWidth = getWidth() * percentX / 100f;
  plainHeight = getHeight() * percentY / 100f;
  float[] matrix = matrix();
  scaledWidth = matrix[DX] - matrix[CX];
  scaledHeight = matrix[DY] - matrix[CY];
  setWidthPercentage(0);
}
origin: com.itextpdf/itextg

/**
 * Scale the width and height of an image to a certain percentage.
 *
 * @param percentX
 *            the scaling percentage of the width
 * @param percentY
 *            the scaling percentage of the height
 */
public void scalePercent(final float percentX, final float percentY) {
  plainWidth = getWidth() * percentX / 100f;
  plainHeight = getHeight() * percentY / 100f;
  float[] matrix = matrix();
  scaledWidth = matrix[DX] - matrix[CX];
  scaledHeight = matrix[DY] - matrix[CY];
  setWidthPercentage(0);
}
origin: wxynihao/book118-downloader

/**
 * 使用图片创建PDF文件
 *
 * @param srcPahOfImg  图片文件夹路径
 * @param desPathOfPdf PDF存储路径
 * @throws DocumentException pdf相关错误
 * @throws IOException       图片相关错误
 */
public static void creatPDF(String srcPahOfImg, String desPathOfPdf) throws DocumentException, IOException {
  File file = new File(srcPahOfImg);
  File[] picFiles = file.listFiles();
  if (picFiles == null || picFiles.length == 0) {
    return;
  }
  List<File> files = Arrays.asList(picFiles);
  //需要根据第一页创建document的大小
  //如果不根据第一页创建,即使修改document的大小也不会生效,困惑
  Image firstImg = Image.getInstance(files.get(0).getCanonicalPath());
  Document document = new Document(new Rectangle(firstImg.getWidth(), firstImg.getHeight()), 0, 0, 0, 0);
  PdfWriter.getInstance(document, new FileOutputStream(desPathOfPdf));
  document.open();
  document.add(firstImg);
  for (int i = 1; i < files.size(); i++) {
    Image img = Image.getInstance(files.get(i).getCanonicalPath());
    document.setPageSize(new Rectangle(img.getWidth(), img.getHeight()));
    document.add(img);
  }
  document.close();
}
origin: com.itextpdf/itextpdf

  img.scaleAbsolute(widthInPoints, heightInPoints);
} else if (widthInPoints > 0) {
  heightInPoints = img.getHeight() * widthInPoints
      / img.getWidth();
  img.scaleAbsolute(widthInPoints, heightInPoints);
} else if (heightInPoints > 0) {
  widthInPoints = img.getWidth() * heightInPoints
      / img.getHeight();
  img.scaleAbsolute(widthInPoints, heightInPoints);
origin: com.itextpdf/itextg

  img.scaleAbsolute(widthInPoints, heightInPoints);
} else if (widthInPoints > 0) {
  heightInPoints = img.getHeight() * widthInPoints
      / img.getWidth();
  img.scaleAbsolute(widthInPoints, heightInPoints);
} else if (heightInPoints > 0) {
  widthInPoints = img.getWidth() * heightInPoints
      / img.getHeight();
  img.scaleAbsolute(widthInPoints, heightInPoints);
origin: com.itextpdf/itextpdf

Rectangle2D rect = tp.getAnchorRect();
com.itextpdf.text.Image image = com.itextpdf.text.Image.getInstance(img, null);
PdfPatternPainter pattern = cb.createPattern(image.getWidth(), image.getHeight());
AffineTransform inverse = this.normalizeMatrix();
inverse.translate(rect.getX(), rect.getY());
inverse.scale(rect.getWidth() / image.getWidth(), -rect.getHeight() / image.getHeight());
double[] mx = new double[6];
inverse.getMatrix(mx);
origin: org.technbolts/gutenberg

public static void adjustOrScaleToFit(Image img, Dimension dim, Rectangle box) {
  if (dim == null) {
    scaleToFit(img, box);
    return;
  }
  float width = img.getWidth();
  switch (dim.unit()) {
    case Percent:
      width = box.getWidth() * dim.amount() / 100f;
      break;
    case Px:
      width = dim.amount();
      break;
  }
  // W --> w
  // H --> h  •••> h = w * H / W
  float height = width * img.getHeight() / img.getWidth();
  img.scaleAbsolute(width, height);
}
origin: com.itextpdf/itextg

public boolean setFieldAsImage(String field, Image image) {
  try {
    if (Float.isNaN(image.getAbsoluteX()))
      image.setAbsolutePosition(0, image.getAbsoluteY());
    if (Float.isNaN(image.getAbsoluteY()))
      image.setAbsolutePosition(image.getAbsoluteY(), 0);
    PdfTemplate tmpl = PdfTemplate.createTemplate(wrt, image.getWidth(), image.getHeight());
    tmpl.addImage(image);
    PdfStream str = tmpl.getFormXObject(PdfStream.NO_COMPRESSION);
    PdfIndirectReference ref = wrt.addToBody(str).getIndirectReference();
    PdfDictionary d = new PdfDictionary();
    d.put(PdfName.N, ref);
    return setField(field, d);
  } catch (Exception de) {
    throw new ExceptionConverter(de);
  }
}
origin: com.itextpdf/itextpdf

writeWord(os, (int)image.getHeight());
writeWord(os, (int)image.getWidth());
writeWord(os, META_DIBSTRETCHBLT);
writeDWord(os, 0x00cc0020);
writeWord(os, (int)image.getHeight());
writeWord(os, (int)image.getWidth());
writeWord(os, 0);
writeWord(os, 0);
writeWord(os, (int)image.getHeight());
writeWord(os, (int)image.getWidth());
writeWord(os, 0);
origin: com.itextpdf/itextpdf

public boolean setFieldAsImage(String field, Image image) {
  try {
    if (Float.isNaN(image.getAbsoluteX()))
      image.setAbsolutePosition(0, image.getAbsoluteY());
    if (Float.isNaN(image.getAbsoluteY()))
      image.setAbsolutePosition(image.getAbsoluteY(), 0);
    PdfTemplate tmpl = PdfTemplate.createTemplate(wrt, image.getWidth(), image.getHeight());
    tmpl.addImage(image);
    PdfStream str = tmpl.getFormXObject(PdfStream.NO_COMPRESSION);
    PdfIndirectReference ref = wrt.addToBody(str).getIndirectReference();
    PdfDictionary d = new PdfDictionary();
    d.put(PdfName.N, ref);
    return setField(field, d);
  } catch (Exception de) {
    throw new ExceptionConverter(de);
  }
}
origin: com.itextpdf/itextpdf

private void writeAttributes(final Image image) {
  if (image != null) {
    this.setAttribute(PdfName.O, PdfName.LAYOUT);
    if (image.getWidth() > 0){
      this.setAttribute(PdfName.WIDTH, new PdfNumber(image.getWidth()));
    }
    if (image.getHeight() > 0){
      this.setAttribute(PdfName.HEIGHT, new PdfNumber(image.getHeight()));
    }
    PdfRectangle rect = new PdfRectangle(image, image.getRotation());
    this.setAttribute(PdfName.BBOX, rect);
    if (image.getBackgroundColor() != null){
      BaseColor color = image.getBackgroundColor();
      this.setAttribute(PdfName.BACKGROUNDCOLOR, new PdfArray(new float[] {color.getRed()/255f, color.getGreen()/255f, color.getBlue()/255f}) );
    }
  }
}
origin: com.itextpdf/itextg

writeWord(os, (int)image.getHeight());
writeWord(os, (int)image.getWidth());
writeWord(os, META_DIBSTRETCHBLT);
writeDWord(os, 0x00cc0020);
writeWord(os, (int)image.getHeight());
writeWord(os, (int)image.getWidth());
writeWord(os, 0);
writeWord(os, 0);
writeWord(os, (int)image.getHeight());
writeWord(os, (int)image.getWidth());
writeWord(os, 0);
origin: com.itextpdf/itextg

private void writeAttributes(final Image image) {
  if (image != null) {
    this.setAttribute(PdfName.O, PdfName.LAYOUT);
    if (image.getWidth() > 0){
      this.setAttribute(PdfName.WIDTH, new PdfNumber(image.getWidth()));
    }
    if (image.getHeight() > 0){
      this.setAttribute(PdfName.HEIGHT, new PdfNumber(image.getHeight()));
    }
    PdfRectangle rect = new PdfRectangle(image, image.getRotation());
    this.setAttribute(PdfName.BBOX, rect);
    if (image.getBackgroundColor() != null){
      BaseColor color = image.getBackgroundColor();
      this.setAttribute(PdfName.BACKGROUNDCOLOR, new PdfArray(new float[] {color.getRed()/255f, color.getGreen()/255f, color.getBlue()/255f}) );
    }
  }
}
origin: qaprosoft/carina

if (scaled) {
  document = new Document(PageSize.A4, 10, 10, 10, 10);
  if (image.getHeight() > (document.getPageSize().getHeight() - 20)
      || image.getScaledWidth() > (document.getPageSize().getWidth() - 20)) {
    image.scaleToFit(document.getPageSize().getWidth() - 20, document.getPageSize().getHeight() - 20);
origin: sc.fiji/Colocalisation_Analysis

document.add(new Paragraph("\n"));
float vertPos = writer.getVerticalPosition(true);
if (vertPos - document.bottom() < image.getHeight()) {
  document.newPage();
} else {
Paragraph paragraph = new Paragraph(image.getWidth() + " x " + image.getHeight());
paragraph.setAlignment(Paragraph.ALIGN_CENTER);
document.add(paragraph);
origin: com.itextpdf/itextpdf

put(PdfName.SUBTYPE, PdfName.IMAGE);
put(PdfName.WIDTH, new PdfNumber(image.getWidth()));
put(PdfName.HEIGHT, new PdfNumber(image.getHeight()));
if (image.getLayer() != null)
  put(PdfName.OC, image.getLayer().getRef());
        decodeparms.put(PdfName.ENDOFBLOCK, PdfBoolean.PDFFALSE);
      decodeparms.put(PdfName.COLUMNS, new PdfNumber(image.getWidth()));
      decodeparms.put(PdfName.ROWS, new PdfNumber(image.getHeight()));
      put(PdfName.DECODEPARMS, decodeparms);
origin: com.itextpdf/itextpdf

saveState();
float w = image.getWidth();
float h = image.getHeight();
concatCTM(a / w, b / w, c / h, d / h, e, f);
rectangle(image);
com.itextpdf.textImagegetHeight

Popular methods of Image

  • getInstance
    gets an instance of an Image
  • getWidth
  • scaleAbsolute
    Scale the image to the dimensions of the rectangle
  • setAbsolutePosition
    Sets the absolute position of the Image.
  • getScaledHeight
    Gets the scaled height of the image.
  • getScaledWidth
    Gets the scaled width of the image.
  • scaleToFit
    Scales the images to the dimensions of the rectangle.
  • scalePercent
    Scale the width and height of an image to a certain percentage.
  • getICCProfile
    Gets the images ICC profile.
  • makeMask
    Make this Image a mask.
  • matrix
    Returns the transformation matrix of the image.
  • setImageMask
    Sets the explicit masking.
  • matrix,
  • setImageMask,
  • setRotation,
  • getAbsoluteX,
  • getAbsoluteY,
  • getAccessibleAttribute,
  • getAccessibleAttributes,
  • getAdditional,
  • getAlignment

Popular in Java

  • Finding current android device location
  • setScale (BigDecimal)
  • onRequestPermissionsResult (Fragment)
  • getSystemService (Context)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now