private void handleSlideEmbeddedPictures(HSLFSlideShow slideshow, XHTMLContentHandler xhtml) throws TikaException, SAXException, IOException { for (HSLFPictureData pic : slideshow.getPictureData()) { String mediaType;
/** * check if a picture with this picture data already exists in this presentation * * @param pictureData The picture data to find in the SlideShow * @return {@code null} if picture data is not found in this slideshow * @since 3.15 beta 3 */ @Override public HSLFPictureData findPictureData(byte[] pictureData) { byte[] uid = HSLFPictureData.getChecksum(pictureData); for (HSLFPictureData pic : getPictureData()) { if (Arrays.equals(pic.getUID(), uid)) { return pic; } } return null; }
public static void main(String args[]) throws IOException { if (args.length < 1) { System.err.println("Usage:"); System.err.println("\tImageExtractor <file>"); return; } HSLFSlideShow ppt = new HSLFSlideShow(new HSLFSlideShowImpl(args[0])); //extract all pictures contained in the presentation int i = 0; for (HSLFPictureData pict : ppt.getPictureData()) { // picture data byte[] data = pict.getData(); PictureType type = pict.getType(); FileOutputStream out = new FileOutputStream("pict_" + i++ + type.extension); out.write(data); out.close(); } ppt.close(); } }
private void handleSlideEmbeddedPictures(HSLFSlideShow slideshow, XHTMLContentHandler xhtml) throws TikaException, SAXException, IOException { for (HSLFPictureData pic : slideshow.getPictureData()) { String mediaType;
private void handleSlideEmbeddedPictures(HSLFSlideShow slideshow, XHTMLContentHandler xhtml) throws TikaException, SAXException, IOException { for (HSLFPictureData pic : slideshow.getPictureData()) { String mediaType;
@SuppressWarnings("resource") @Override public HSLFPictureData getPictureData(){ HSLFSlideShow ppt = getSheet().getSlideShow(); List<HSLFPictureData> pict = ppt.getPictureData(); EscherBSERecord bse = getEscherBSERecord(); if (bse == null){ LOG.log(POILogger.ERROR, "no reference to picture data found "); } else { for (HSLFPictureData pd : pict) { if (pd.getOffset() == bse.getOffset()){ return pd; } } LOG.log(POILogger.ERROR, "no picture found for our BSE offset " + bse.getOffset()); } return null; }
/** * <code>PictureData</code> object used in a texture, pattern of picture fill. */ @SuppressWarnings("resource") public HSLFPictureData getPictureData(){ AbstractEscherOptRecord opt = shape.getEscherOptRecord(); EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE); if (p == null) { return null; } HSLFSlideShow ppt = shape.getSheet().getSlideShow(); List<HSLFPictureData> pict = ppt.getPictureData(); Document doc = ppt.getDocumentRecord(); EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer(); EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER); java.util.List<EscherRecord> lst = bstore.getChildRecords(); int idx = p.getPropertyValue(); if (idx == 0){ LOG.log(POILogger.WARN, "no reference to picture data found "); } else { EscherBSERecord bse = (EscherBSERecord)lst.get(idx - 1); for (HSLFPictureData pd : pict) { if (pd.getOffset() == bse.getOffset()){ return pd; } } } return null; }