/** * @see com.itextpdf.text.pdf.PdfContentByte#addImage(com.itextpdf.text.Image, float, float, float, float, float, float) */ public void addImage(Image image, float a, float b, float c, float d, float e, float f) throws DocumentException { if (stencil && !image.isMask()) checkNoColor(); super.addImage(image, a, b, c, d, e, f); }
/** * @see com.itextpdf.text.pdf.PdfContentByte#addImage(com.itextpdf.text.Image, float, float, float, float, float, float) */ public void addImage(Image image, float a, float b, float c, float d, float e, float f) throws DocumentException { if (stencil && !image.isMask()) checkNoColor(); super.addImage(image, a, b, c, d, e, f); }
public Image getWatermarkedImage(PdfContentByte cb, Image img, String watermark) throws DocumentException { float width = img.getScaledWidth(); float height = img.getScaledHeight(); PdfTemplate template = cb.createTemplate(width, height); template.addImage(img, width, 0, 0, height, 0, 0); ColumnText.showTextAligned(template, Element.ALIGN_CENTER, new Phrase(watermark, FONT), width / 2, height / 2, 30); return Image.getInstance(template); }
PdfTemplate t = writer.getDirectContent().createTemplate(850, 600); t.rectangle(x+20,y+20, width-40, height-40); t.clip(); t.newPath(); t.addImage(img, width, 0, 0, height, x, y);
public Image cropImage(PdfWriter writer, Image image, float leftReduction, float rightReduction, float topReduction, float bottomReduction) throws DocumentException { float width = image.getScaledWidth(); float height = image.getScaledHeight(); PdfTemplate template = writer.getDirectContent().createTemplate( width - leftReduction - rightReduction, height - topReduction - bottomReduction); template.addImage(image, width, 0, 0, height, -leftReduction, -bottomReduction); return Image.getInstance(template); }
public static Image cropImage(Image image, PdfWriter writer, float x, float y, float width, float height) throws DocumentException { PdfContentByte cb = writer.getDirectContent(); PdfTemplate t = cb.createTemplate(width, height); float origWidth = image.getScaledWidth(); float origHeight = image.getScaledHeight(); t.addImage(image, origWidth, 0, 0, origHeight, -x, -y); return Image.getInstance(t); }
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); } }
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); } }
tp.setBoundingBox(new Rectangle(image)); writer.addDirectTemplateSimple(tp, PdfName.FRM); tp.addImage(image, image.getWidth(), 0, 0, image.getHeight(), 0, 0); haveIcon = true; boundingBoxWidth = tp.getBoundingBox().getWidth();
tp.setBoundingBox(new Rectangle(image)); writer.addDirectTemplateSimple(tp, PdfName.FRM); tp.addImage(image, image.getWidth(), 0, 0, image.getHeight(), 0, 0); haveIcon = true; boundingBoxWidth = tp.getBoundingBox().getWidth();