org.apache.poi.xwpf.usermodel
Class XWPFPictureData

java.lang.Object
  extended by org.apache.poi.POIXMLDocumentPart
      extended by org.apache.poi.xwpf.usermodel.XWPFPictureData

public class XWPFPictureData
extends POIXMLDocumentPart

Author:
Philipp Epp

Field Summary
protected static POIXMLRelation[] RELATIONS
          Relationships for each known picture type
 
Fields inherited from class org.apache.poi.POIXMLDocumentPart
DEFAULT_XML_OPTIONS
 
Constructor Summary
protected XWPFPictureData()
          Create a new XWPFGraphicData node
  XWPFPictureData(PackagePart part, PackageRelationship rel)
          Construct XWPFPictureData from a package part
 
Method Summary
 byte[] getData()
          Gets the picture data as a byte array.
 java.lang.String getFileName()
          Returns the file name of the image, eg image7.jpg .
 int getPictureType()
          Return an integer constant that specifies type of this picture
 java.lang.String suggestFileExtension()
          Suggests a file extension for this image.
 
Methods inherited from class org.apache.poi.POIXMLDocumentPart
addRelation, commit, createRelationship, createRelationship, createRelationship, getPackagePart, getPackageRelationship, getParent, getRelations, onDocumentCreate, onDocumentRead, onSave, read, rebase, removeRelation, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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,
                       PackageRelationship rel)
Construct XWPFPictureData from a package part

Parameters:
part - the package part holding the drawing data,
rel - the package relationship holding this drawing, the relationship type must be http://schemas.openxmlformats.org/officeDocument/2006/relationships/image
Method Detail

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 java.lang.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 java.lang.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
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


Copyright 2010 The Apache Software Foundation or its licensors, as applicable.