List of usage examples for org.apache.poi.hpsf Thumbnail Thumbnail
public Thumbnail(final byte[] thumbnailData)
Creates a Thumbnail instance and initializes with the specified image bytes.
From source file:com.oneis.graphics.ThumbnailFinder.java
License:Mozilla Public License
/** * Try and get a thumbnail from an old Microsoft Office document *//*from w ww .j av a2 s . com*/ private void findFromOldMSOffice() { try { File poiFilesystem = new File(inFilename); // Open the POI filesystem. InputStream is = new FileInputStream(poiFilesystem); POIFSFileSystem poifs = new POIFSFileSystem(is); is.close(); // Read the summary information. DirectoryEntry dir = poifs.getRoot(); DocumentEntry siEntry = (DocumentEntry) dir.getEntry(SummaryInformation.DEFAULT_STREAM_NAME); DocumentInputStream dis = new DocumentInputStream(siEntry); PropertySet ps = new PropertySet(dis); dis.close(); SummaryInformation si = new SummaryInformation(ps); if (si != null) { byte[] thumbnailData = si.getThumbnail(); if (thumbnailData != null) { Thumbnail thumbnail = new Thumbnail(thumbnailData); byte[] wmf = thumbnail.getThumbnailAsWMF(); // Got something! thumbnailDimensions = tryWMFFormat(new ByteArrayInputStream(wmf), outFilename, outFormat, maxDimension); } } } catch (Exception e) { logIgnoredException("ThumbnailFinder Apache POI file reading failed", e); } }