private com.itextpdf.text.Image buildPdfImage(String base64Data, int width,int height) throws Exception{ com.itextpdf.text.Image pdfImg=null; InputStream input=ImageUtils.base64DataToInputStream(base64Data); try{ byte[] bytes=IOUtils.toByteArray(input); pdfImg=com.itextpdf.text.Image.getInstance(bytes); float imgWidth=pdfImg.getWidth(); float imgHeight=pdfImg.getHeight(); if(width==0){ width=Float.valueOf(imgWidth).intValue(); } if(height==0){ height=Float.valueOf(imgHeight).intValue(); } width=UnitUtils.pixelToPoint(width-2); height=UnitUtils.pixelToPoint(height-2); pdfImg.scaleToFit(width,height); }finally{ IOUtils.closeQuietly(input); } return pdfImg; } }
public static Image getInstance(final byte imgb[]) throws BadElementException, MalformedURLException, IOException { return getInstance(imgb, false); }
public ExtendedImage( Image image, float offsetY ) { super( image ); this.image = Image.getInstance( image ); this.offsetY = offsetY; }
public static Image getInstance(final byte imgb[]) throws BadElementException, MalformedURLException, IOException { return getInstance(imgb, false); }
public static Image getInstance(final URL url) throws BadElementException, MalformedURLException, IOException { return Image.getInstance(url, false); }
public static Image getInstance(final URL url) throws BadElementException, MalformedURLException, IOException { return Image.getInstance(url, false); }
/** Gets an <CODE>Image</CODE> with the barcode. A successful call to the method <CODE>generate()</CODE> * before calling this method is required. * @return the barcode <CODE>Image</CODE> * @throws BadElementException on error */ public Image createImage() throws BadElementException { if (image == null) return null; byte g4[] = CCITTG4Encoder.compress(image, width + 2 * ws, height + 2 * ws); return Image.getInstance(width + 2 * ws, height + 2 * ws, false, Image.CCITTG4, 0, g4, null); }
/** Gets an <CODE>Image</CODE> with the barcode. A successful call to the method <CODE>generate()</CODE> * before calling this method is required. * @return the barcode <CODE>Image</CODE> * @throws BadElementException on error */ public Image createImage() throws BadElementException { if (image == null) return null; byte g4[] = CCITTG4Encoder.compress(image, width + 2 * ws, height + 2 * ws); return Image.getInstance(width + 2 * ws, height + 2 * ws, false, Image.CCITTG4, 0, g4, null); }
public Object clone() { return new ITextFSImage(Image.getInstance(_image)); } }
public static Image getInstance(final String filename, boolean recoverFromImageError) throws IOException, BadElementException { return getInstance(Utilities.toURL(filename), recoverFromImageError); }
public static Image getInstance(final String filename, boolean recoverFromImageError) throws IOException, BadElementException { return getInstance(Utilities.toURL(filename), recoverFromImageError); }
/** * Gets an instance of an Image. * * @param filename * a filename * @return an object of type <CODE>Gif</CODE>,<CODE>Jpeg</CODE> or * <CODE>Png</CODE> * @throws BadElementException * @throws MalformedURLException * @throws IOException */ public static Image getInstance(final String filename) throws BadElementException, MalformedURLException, IOException { return getInstance(Utilities.toURL(filename)); }
/** * Gets an instance of an Image. * * @param filename * a filename * @return an object of type <CODE>Gif</CODE>,<CODE>Jpeg</CODE> or * <CODE>Png</CODE> * @throws BadElementException * @throws MalformedURLException * @throws IOException */ public static Image getInstance(final String filename) throws BadElementException, MalformedURLException, IOException { return getInstance(Utilities.toURL(filename)); }
/** Gets an <CODE>Image</CODE> with the barcode. The image will have to be * scaled in the Y direction by <CODE>yHeight</CODE>for the barcode * to have the right printing aspect. * @return the barcode <CODE>Image</CODE> * @throws BadElementException on error */ public Image getImage() throws BadElementException { paintCode(); byte g4[] = CCITTG4Encoder.compress(outBits, bitColumns, codeRows); return Image.getInstance(bitColumns, codeRows, false, Image.CCITTG4, (options & PDF417_INVERT_BITMAP) == 0 ? 0 : Image.CCITT_BLACKIS1, g4, null); }
/** Gets an <CODE>Image</CODE> with the barcode. The image will have to be * scaled in the Y direction by <CODE>yHeight</CODE>for the barcode * to have the right printing aspect. * @return the barcode <CODE>Image</CODE> * @throws BadElementException on error */ public Image getImage() throws BadElementException { paintCode(); byte g4[] = CCITTG4Encoder.compress(outBits, bitColumns, codeRows); return Image.getInstance(bitColumns, codeRows, false, Image.CCITTG4, (options & PDF417_INVERT_BITMAP) == 0 ? 0 : Image.CCITT_BLACKIS1, g4, null); }
/** Creates an <CODE>Image</CODE> with the barcode. * @param cb the <CODE>PdfContentByte</CODE> to create the <CODE>Image</CODE>. It * serves no other use * @param barColor the color of the bars. It can be <CODE>null</CODE> * @param textColor the color of the text. It can be <CODE>null</CODE> * @return the <CODE>Image</CODE> * @see #placeBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor) */ public Image createImageWithBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor) { try { return Image.getInstance(createTemplateWithBarcode(cb, barColor, textColor)); } catch (Exception e) { throw new ExceptionConverter(e); } }
/** Creates an <CODE>Image</CODE> with the barcode. * @param cb the <CODE>PdfContentByte</CODE> to create the <CODE>Image</CODE>. It * serves no other use * @param barColor the color of the bars. It can be <CODE>null</CODE> * @param textColor the color of the text. It can be <CODE>null</CODE> * @return the <CODE>Image</CODE> * @see #placeBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor) */ public Image createImageWithBarcode(PdfContentByte cb, BaseColor barColor, BaseColor textColor) { try { return Image.getInstance(createTemplateWithBarcode(cb, barColor, textColor)); } catch (Exception e) { throw new ExceptionConverter(e); } }
/** Gets an <CODE>Image</CODE> with the barcode. * @return the barcode <CODE>Image</CODE> * @throws BadElementException on error */ public Image getImage() throws BadElementException { byte[] b = getBitMatrix(); byte g4[] = CCITTG4Encoder.compress(b, bm.getWidth(), bm.getHeight()); return Image.getInstance(bm.getWidth(), bm.getHeight(), false, Image.CCITTG4, Image.CCITT_BLACKIS1, g4, null); }
/** Gets an <CODE>Image</CODE> with the barcode. * @return the barcode <CODE>Image</CODE> * @throws BadElementException on error */ public Image getImage() throws BadElementException { byte[] b = getBitMatrix(); byte g4[] = CCITTG4Encoder.compress(b, bm.getWidth(), bm.getHeight()); return Image.getInstance(bm.getWidth(), bm.getHeight(), false, Image.CCITTG4, Image.CCITT_BLACKIS1, g4, null); }
private ImageResource loadEmbeddedBase64ImageResource(final String uri) { try { byte[] buffer = ImageUtil.getEmbeddedBase64Image(uri); Image image = Image.getInstance(buffer); scaleToOutputResolution(image); return new ImageResource(null, new ITextFSImage(image)); } catch (Exception e) { XRLog.exception("Can't read XHTML embedded image.", e); } return new ImageResource(null, null); }