List of usage examples for com.itextpdf.text Image setInterpolation
public void setInterpolation(final boolean interpolation)
From source file:org.durel.mydooble.ImageItem.java
License:Open Source License
@Override public void toPDF(PDF out, int i) { super.toPDF(out, i); try {//from w w w .jav a 2 s .c o m Image img = Image.getInstance(image); img.setDpi(288, 288); img.setInterpolation(true); float ih = (float) (img.getHeight()); float iw = (float) (img.getWidth()); if (ih > h || iw > w) { float xratio = iw / w; float yratio = ih / h; float ratio = Math.max(xratio, yratio); log.info("ih: " + ih + " - iw: " + iw + " - xratio: " + xratio + " - yratio: " + yratio + " - ratio: " + ratio + " --> " + (int) (iw / ratio) + "x" + (int) (ih / ratio)); img.scalePercent(100 / ratio); } PdfContentByte cb = out.writer.getDirectContent(); float x = bx + (c * (w + m)) + m; float y = by + (r * (h + m)) + m; img.setAbsolutePosition(x, y); cb.addImage(img); } catch (DocumentException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }