public BufferedImage getImage(final Rendition rendition, final Dimension dim) throws IOException { final Asset asset = rendition.getAsset(); final byte[] picture = (byte[]) extractMetadata(asset).getProperty(META_KEY_THUMBNAIL); // if we have an embedded image if (picture != null) { return new Layer(new ByteArrayInputStream(picture), dim).getImage(); } // according to the spec, a thumbnail representation of a document should be generated by // default when the // file is saved. log.warn("Failed to retrieve thumbnail for {}", asset.getPath()); return null; }
public BufferedImage getImage(final Rendition rendition) throws IOException { ExtractedMetadata metadata = extractMetadata(rendition.getAsset()); String text = (String) metadata.getMetaDataProperty("Content"); if (text != null && text.length() > 0) { // create text layer final Layer layer = new Layer(500, 600, Color.WHITE); layer.setPaint(Color.black); Font font = new Font("Arial", 12); String displayText = getDisplayText(text, 600, 12); layer.drawText(10, 10, 500, 600, displayText, font, Font.ALIGN_LEFT, 0, 0); layer.crop(new Rectangle(510, 600)); return layer.getImage(); } else { return null; } }