Package org.apache.poi.xwpf.usermodel
Class XWPFPictureData
java.lang.Object
org.apache.poi.ooxml.POIXMLDocumentPart
org.apache.poi.xwpf.usermodel.XWPFPictureData
Raw picture data, normally attached to a WordprocessingML Drawing.
As a rule, pictures are stored in the /word/media/ part of a WordprocessingML package.
- Author:
- Philipp Epp
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
POIXMLDocumentPart.RelationPart
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final POIXMLRelation[]
Relationships for each known picture type -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Create a new XWPFGraphicData nodeXWPFPictureData
(PackagePart part) Construct XWPFPictureData from a package part -
Method Summary
Modifier and TypeMethodDescriptionboolean
byte[]
getData()
Gets the picture data as a byte array.Returns the file name of the image, eg image7.jpg .int
Return an integer constant that specifies type of this pictureint
hashCode()
protected void
Fired when a package part is readprotected void
*PictureData objects store the actual content in the part directly without keeping a copy like all others therefore we need to handle them differently.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, isCommited, onDocumentCreate, onDocumentRemove, onSave, read, rebase, removeRelation, removeRelation, removeRelation, setCommited, toString
-
Field Details
-
RELATIONS
Relationships for each known picture type
-
-
Constructor Details
-
XWPFPictureData
protected XWPFPictureData()Create a new XWPFGraphicData node -
XWPFPictureData
Construct XWPFPictureData from a package part- Parameters:
part
- the package part holding the drawing data,- Since:
- POI 3.14-Beta1
-
-
Method Details
-
onDocumentRead
Description copied from class:POIXMLDocumentPart
Fired when a package part is read- Overrides:
onDocumentRead
in 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
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
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
- See Also:
-
getChecksum
-
equals
-
hashCode
public int hashCode() -
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:
prepareForCommit
in classPOIXMLDocumentPart
-