/** * Adds an <CODE>Image</CODE> to the page. The <CODE>Image</CODE> must have * absolute positioning. * @param image the <CODE>Image</CODE> object * @throws DocumentException if the <CODE>Image</CODE> does not have absolute positioning */ public void addImage(Image image) throws DocumentException { addImage(image, false); }
/** * Adds an <CODE>Image</CODE> to the page. The <CODE>Image</CODE> must have * absolute positioning. * @param image the <CODE>Image</CODE> object * @throws DocumentException if the <CODE>Image</CODE> does not have absolute positioning */ public void addImage(Image image) throws DocumentException { addImage(image, false); }
/** * Adds an <CODE>Image</CODE> to the page. The <CODE>Image</CODE> must have * absolute positioning. * @param image the <CODE>Image</CODE> object * @throws DocumentException if the <CODE>Image</CODE> does not have absolute positioning */ public void addImage(Image image) throws DocumentException { addImage(image, false); }
image.setAbsolutePosition((rect.getLeft() + rect.getRight()) / 2, rect.getBottom() + 18); PdfContentByte canvas = writer.getDirectContent(); canvas.addImage(image);
Image image = Image.getInstance(stream.toByteArray()); PdfContentByte overContent = stamper.getOverContent(1); overContent.addImage(image);
/** * Adds an <CODE>Image</CODE> to the page. The positioning of the <CODE>Image</CODE> * is done with the transformation matrix. To position an <CODE>image</CODE> at (x,y) * use addImage(image, image_width, 0, 0, image_height, x, y). * @param image the <CODE>Image</CODE> object * @param a an element of the transformation matrix * @param b an element of the transformation matrix * @param c an element of the transformation matrix * @param d an element of the transformation matrix * @param e an element of the transformation matrix * @param f an element of the transformation matrix * @throws DocumentException on error */ public void addImage(Image image, float a, float b, float c, float d, float e, float f) throws DocumentException { addImage(image, a, b, c, d, e, f, false); }
/** * Adds an <CODE>Image</CODE> to the page. The positioning of the <CODE>Image</CODE> * is done with the transformation matrix. To position an <CODE>image</CODE> at (x,y) * use addImage(image, image_width, 0, 0, image_height, x, y). * @param image the <CODE>Image</CODE> object * @param a an element of the transformation matrix * @param b an element of the transformation matrix * @param c an element of the transformation matrix * @param d an element of the transformation matrix * @param e an element of the transformation matrix * @param f an element of the transformation matrix * @throws DocumentException on error */ public void addImage(Image image, float a, float b, float c, float d, float e, float f) throws DocumentException { addImage(image, a, b, c, d, e, f, false); }
@Override public void addImage( Image image, float a, float b, float c, float d, float e, float f, boolean inlineImage ) throws DocumentException { if ( image instanceof ExtendedImage ) { ExtendedImage extImg = (ExtendedImage) image; super.addImage( extImg.getImage(), a, b, c, d, e, f + extImg.getOffsetY(), inlineImage ); } else { super.addImage( image, a, b, c, d, e, f, inlineImage ); } } }
@Override public void addImage( Image image, float a, float b, float c, float d, float e, float f, boolean inlineImage ) throws DocumentException { if ( image instanceof ExtendedImage ) { ExtendedImage extImg = (ExtendedImage) image; super.addImage( extImg.getImage(), a, b, c, d, e, f + extImg.getOffsetY(), inlineImage ); } else { super.addImage( image, a, b, c, d, e, f, inlineImage ); } } }
Document document = new Document(page); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(dest)); document.open(); PdfContentByte canvas = writer.getDirectContentUnder(); canvas.addImage(image, width, 0, 0, height, 0, -height / 2); document.newPage(); canvas.addImage(image, width, 0, 0, height, 0, 0); document.newPage(); canvas.addImage(image, width, 0, 0, height, -width / 2, - height / 2); document.newPage(); canvas.addImage(image, width, 0, 0, height, -width / 2, 0); document.close();
class ImageBackground implements PdfPCellEvent { protected Image image; public ImageBackground(Image image) { this.image = image; } public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) { PdfContentByte cb = canvases[PdfPTable.BACKGROUNDCANVAS]; Image.scaleToFit(position.getWidth() , position.getHeight()); Image.setAbsolutePosition(position.getBottom(), position.getLeft()); cb.addImage(image); } }
PdfContentByte content = stamper.getOverContent(reader.getNumberOfPages()); Image image = Image.getInstance(new URL("E:/signature/signature.png")); image.setAbsolutePosition(450,650); image.scaleAbsolute(200,200); content.addImage(image); reader.close(); return output.toByteArray();
PdfReader reader = new PdfReader("HelloWorld.pdf"); PdfStamper pdfStamper = new PdfStamper(reader, new FileOutputStream("NewHelloWorld.pdf")); Image image = Image.getInstance("MyWatermark.png"); for(int i=1; i<= reader.getNumberOfPages(); i++){ PdfContentByte content = pdfStamper.getUnderContent(i); image.setAbsolutePosition(150f, 750f); content.addImage(image); } pdfStamper.close();
PdfReader reader = new PdfReader("template.pdf"); PdfStamper stamper = new PdfStamper( reader, new FileOutputStream("output.pdf")); PdfContentByte content = stamper.getOverContent(1); // first page == 1 Image image = Image.createInstance("someImage.png"); image.setAbsolutePosition( x, y ); image.setAbsoluteHeight( hei ); image.setAbsoluteWidth( wid ); content.addImage(image); // instead of absolutely positioning the image, you can do: //content.addImage( image, wid, 0f, 0f, hei, x, y ); // that's a transformation matrix, you can skew, rotate, scale, etc. stamper.close();
public void addImage(Image image, float a, float b, float c, float d, float e, float f, boolean inlineImage) throws DocumentException { if (!colorized && (!image.isMask() || !(image.getBpc() == 1 || image.getBpc() > 0xff))) throw new DocumentException("Not colorized Typed3 fonts only accept mask images."); super.addImage(image, a, b, c, d, e, f, inlineImage); }
public void addImage(Image image, float a, float b, float c, float d, float e, float f, boolean inlineImage) throws DocumentException { if (!colorized && (!image.isMask() || !(image.getBpc() == 1 || image.getBpc() > 0xff))) throw new DocumentException(MessageLocalization.getComposedMessage("not.colorized.typed3.fonts.only.accept.mask.images")); super.addImage(image, a, b, c, d, e, f, inlineImage); }
public void addImage(Image image, float a, float b, float c, float d, float e, float f, boolean inlineImage) throws DocumentException { if (!colorized && (!image.isMask() || !(image.getBpc() == 1 || image.getBpc() > 0xff))) throw new DocumentException(MessageLocalization.getComposedMessage("not.colorized.typed3.fonts.only.accept.mask.images")); super.addImage(image, a, b, c, d, e, f, 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(Image image, boolean inlineImage) throws DocumentException { if (!image.hasAbsoluteY()) throw new DocumentException("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(Image image, 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(Image image, 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); }