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); } }
/** * Adds an <CODE>Image</CODE> to the page. The <CODE>Image</CODE> must have * absolute positioning. The image can be placed inline. * @param image the <CODE>Image</CODE> object * @param inlineImage <CODE>true</CODE> to place this image inline, <CODE>false</CODE> otherwise * @throws DocumentException if the <CODE>Image</CODE> does not have absolute positioning */ public void addImage(final Image image, final boolean inlineImage) throws DocumentException { if (!image.hasAbsoluteY()) throw new DocumentException(MessageLocalization.getComposedMessage("the.image.must.have.absolute.positioning")); float matrix[] = image.matrix(); matrix[Image.CX] = image.getAbsoluteX() - matrix[Image.CX]; matrix[Image.CY] = image.getAbsoluteY() - matrix[Image.CY]; addImage(image, matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5], inlineImage); }
/** * Adds an <CODE>Image</CODE> to the page. The <CODE>Image</CODE> must have * absolute positioning. The image can be placed inline. * @param image the <CODE>Image</CODE> object * @param inlineImage <CODE>true</CODE> to place this image inline, <CODE>false</CODE> otherwise * @throws DocumentException if the <CODE>Image</CODE> does not have absolute positioning */ public void addImage(final Image image, final boolean inlineImage) throws DocumentException { if (!image.hasAbsoluteY()) throw new DocumentException(MessageLocalization.getComposedMessage("the.image.must.have.absolute.positioning")); float matrix[] = image.matrix(); matrix[Image.CX] = image.getAbsoluteX() - matrix[Image.CX]; matrix[Image.CY] = image.getAbsoluteY() - matrix[Image.CY]; addImage(image, matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5], inlineImage); }