/** * get the next free ImageNumber * * @param format * @return the next free ImageNumber * @throws InvalidFormatException If the format of the picture is not known. */ public int getNextPicNameNumber(int format) throws InvalidFormatException { int img = getAllPackagePictures().size() + 1; String proposal = XWPFPictureData.RELATIONS[format].getFileName(img); PackagePartName createPartName = PackagingURIHelper.createPartName(proposal); while (this.getPackage().getPart(createPartName) != null) { img++; proposal = XWPFPictureData.RELATIONS[format].getFileName(img); createPartName = PackagingURIHelper.createPartName(proposal); } return img; }
XWPFDocument wordDocument = new XWPFDocument(new FileInputStream(docxFile)); ArrayList<PackagePart> packageParts= wordDocument.getPackage().getPartsByRelationshipType ("http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"); PackagePart packagePart = packageParts.get(0); FileOutputStream fos = new FileOutputStream("c:\\temp\\thumb.emf"); IOUtils.copy(packagePart.getInputStream(), fos);
/** * get the next free ImageNumber * @param format * @return the next free ImageNumber * @throws InvalidFormatException */ public int getNextPicNameNumber(int format) throws InvalidFormatException { int img = getAllPackagePictures().size() + 1; String proposal = XWPFPictureData.RELATIONS[format].getFileName(img); PackagePartName createPartName = PackagingURIHelper.createPartName(proposal); while (this.getPackage().getPart(createPartName) != null) { img++; proposal = XWPFPictureData.RELATIONS[format].getFileName(img); createPartName = PackagingURIHelper.createPartName(proposal); } return img; }
/** * get the next free ImageNumber * * @param format * @return the next free ImageNumber * @throws InvalidFormatException If the format of the picture is not known. */ public int getNextPicNameNumber(int format) throws InvalidFormatException { int img = getAllPackagePictures().size() + 1; String proposal = XWPFPictureData.RELATIONS[format].getFileName(img); PackagePartName createPartName = PackagingURIHelper.createPartName(proposal); while (this.getPackage().getPart(createPartName) != null) { img++; proposal = XWPFPictureData.RELATIONS[format].getFileName(img); createPartName = PackagingURIHelper.createPartName(proposal); } return img; }