List of usage examples for com.lowagie.text.pdf PdfContentByte addImage
public void addImage(Image image, float a, float b, float c, float d, float e, float f, boolean inlineImage) throws DocumentException
Image
to the page. From source file:es.gob.afirma.signers.pades.PdfPreProcessor.java
License:Open Source License
/** Sobreimpone una imagen JPEG en un documento PDF. * @param jpegImage Imagen JPEG/*from ww w. j av a 2 s . co m*/ * @param width Ancho de la imagen * @param height Alto de la imagen * @param left Distancia de la imagen al borde izquiero de la página del PDF * @param bottom Distancia de la imagen al borde inferior de la página del PDF * @param pageNum Número de página del PDF donde insertar la imagen * (la numeración comienza en 1) * @param url URL a la que enlazará la imagen si queremos que esta sea un hipervínculo * (puede ser <code>null</code>) * @param stp Estampador PDF de iText * @throws IOException En caso de errores de entrada / salida */ public static void addImage(final byte[] jpegImage, final int width, final int height, final int left, final int bottom, final int pageNum, final String url, final PdfStamper stp) throws IOException { final PdfContentByte content = stp.getOverContent(pageNum); try { final Image image = new Jpeg(jpegImage); if (url != null) { image.setAnnotation(new Annotation(0, 0, 0, 0, url)); } content.addImage(image, // Image width, // Image width 0, 0, height, // Image height left, // Lower left X position of the image bottom, // Lower left Y position of the image false // Inline ); } catch (final DocumentException e) { throw new IOException("Error durante la insercion de la imagen en el PDF: " + e, e); //$NON-NLS-1$ } }