Package org.apache.poi.xwpf.usermodel
Class XWPFPictureData
- java.lang.Object
-
- org.apache.poi.ooxml.POIXMLDocumentPart
-
- org.apache.poi.xwpf.usermodel.XWPFPictureData
-
public class XWPFPictureData extends POIXMLDocumentPart
Raw picture data, normally attached to a WordprocessingML Drawing. As a rule, pictures are stored in the /word/media/ part of a WordprocessingML package.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
POIXMLDocumentPart.RelationPart
-
-
Field Summary
Fields Modifier and Type Field Description protected static POIXMLRelation[]RELATIONSRelationships for each known picture type
-
Constructor Summary
Constructors Modifier Constructor Description protectedXWPFPictureData()Create a new XWPFGraphicData nodeXWPFPictureData(PackagePart part)Construct XWPFPictureData from a package part
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)LonggetChecksum()byte[]getData()Gets the picture data as a byte array.StringgetFileName()Returns the file name of the image, eg image7.jpg .static intgetMaxImageSize()intgetPictureType()Return an integer constant that specifies type of this pictureinthashCode()protected voidonDocumentRead()Fired when a package part is readprotected voidprepareForCommit()*PictureData objects store the actual content in the part directly without keeping a copy like all others therefore we need to handle them differently.static voidsetMaxImageSize(int length)StringsuggestFileExtension()Suggests a file extension for this image.-
Methods inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
_invokeOnDocumentRead, addRelation, commit, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getRelationById, getRelationId, getRelationPartById, getRelationParts, getRelations, getTargetPart, isCommitted, onDocumentCreate, onDocumentRemove, onSave, read, rebase, removeRelation, removeRelation, removeRelation, setCommitted, toString
-
-
-
-
Field Detail
-
RELATIONS
protected static final POIXMLRelation[] RELATIONS
Relationships for each known picture type
-
-
Constructor Detail
-
XWPFPictureData
protected XWPFPictureData()
Create a new XWPFGraphicData node
-
XWPFPictureData
public XWPFPictureData(PackagePart part)
Construct XWPFPictureData from a package part- Parameters:
part- the package part holding the drawing data,- Since:
- POI 3.14-Beta1
-
-
Method Detail
-
setMaxImageSize
public static void setMaxImageSize(int length)
- Parameters:
length- the max image size allowed for XSSF pictures
-
getMaxImageSize
public static int getMaxImageSize()
- Returns:
- the max image size allowed for XSSF pictures
-
onDocumentRead
protected void onDocumentRead() throws IOExceptionDescription copied from class:POIXMLDocumentPartFired when a package part is read- Overrides:
onDocumentReadin classPOIXMLDocumentPart- Throws:
IOException- a subclass may throw an IOException when a document is read
-
getData
public byte[] getData()
Gets the picture data as a byte array.Note, that this call might be expensive since all the picture data is copied into a temporary byte array. You can grab the picture data directly from the underlying package part as follows:
InputStream is = getPackagePart().getInputStream();- Returns:
- the Picture data.
-
getFileName
public String getFileName()
Returns the file name of the image, eg image7.jpg . The original filename isn't always available, but if it can be found it's likely to be in the CTDrawing
-
suggestFileExtension
public String suggestFileExtension()
Suggests a file extension for this image.- Returns:
- the file extension.
-
getPictureType
public int getPictureType()
Return an integer constant that specifies type of this picture- Returns:
- an integer constant that specifies type of this picture, returns 0 if an unknown type
- See Also:
Document.PICTURE_TYPE_EMF,Document.PICTURE_TYPE_WMF,Document.PICTURE_TYPE_PICT,Document.PICTURE_TYPE_JPEG,Document.PICTURE_TYPE_PNG,Document.PICTURE_TYPE_DIB
-
getChecksum
public Long getChecksum()
-
prepareForCommit
protected void prepareForCommit()
*PictureData objects store the actual content in the part directly without keeping a copy like all others therefore we need to handle them differently.- Overrides:
prepareForCommitin classPOIXMLDocumentPart
-
-