Package org.apache.poi.hwpf
Class HWPFDocument
java.lang.Object
org.apache.poi.POIDocument
org.apache.poi.hwpf.HWPFDocumentCore
org.apache.poi.hwpf.HWPFDocument
- All Implemented Interfaces:
Closeable
,AutoCloseable
This class acts as the bucket that we throw all of the Word data structures
into.
-
Field Summary
Fields inherited from class org.apache.poi.hwpf.HWPFDocumentCore
_cbt, _fib, _ft, _lt, _mainStream, _objectPool, _pbt, _ss, _st, FIB_BASE_LEN, RC4_REKEYING_INTERVAL, STREAM_OBJECT_POOL, STREAM_TABLE_0, STREAM_TABLE_1, STREAM_WORD_DOCUMENT
-
Constructor Summary
ConstructorsConstructorDescriptionHWPFDocument
(InputStream istream) This constructor loads a Word document from an InputStream.HWPFDocument
(DirectoryNode directory) This constructor loads a Word document from a specific point in a POIFSFileSystem, probably not the default.HWPFDocument
(POIFSFileSystem pfilesystem) This constructor loads a Word document from a POIFSFileSystem -
Method Summary
Modifier and TypeMethodDescriptionint
Returns the character length of a document.void
delete
(int start, int length) Returns theRange
which covers all annotations.byte[]
Returns theRange
which covers all endnotes.Returns user-friendly interface to access documentField
sDeprecated.POI 3.8.Returns theRange
which covers all the Footnotes.Returns the range which covers all "Header Stories".Returns theRange
which covers all textboxes.Returns the range that covers all text in the file, including main text, footnotes, headers and commentsgetRange()
Returns the range which covers the whole of the document, but excludes any headers and footers.Gets a reference to the revision mark author table, which holds the revision mark authors for the document.Gets a reference to the saved -by table, which holds the save history for the document.byte[]
getText()
Internal method to access document textint
registerList
(HWPFList list) void
write()
Write out the word file that is represented by this class, to the currently openFile
, via the writeablePOIFSFileSystem
it was opened as.void
Writes out the word file that is represented by an instance of this class.void
write
(OutputStream out) Writes out the word file that is represented by an instance of this class.Methods inherited from class org.apache.poi.hwpf.HWPFDocumentCore
getCharacterTable, getDocumentEntryBytes, getDocumentText, getEncryptionInfo, getFileInformationBlock, getFontTable, getListTables, getMainStream, getObjectsPool, getParagraphTable, getSectionTable, getStyleSheet, updateEncryptionInfo, verifyAndBuildPOIFS
Methods inherited from class org.apache.poi.POIDocument
clearDirectory, close, createInformationProperties, getDirectory, getDocumentSummaryInformation, getEncryptedPropertyStreamName, getPropertySet, getPropertySet, getSummaryInformation, initDirectory, readProperties, replaceDirectory, validateInPlaceWritePossible, writeProperties, writeProperties, writeProperties
-
Constructor Details
-
HWPFDocument
This constructor loads a Word document from an InputStream.- Parameters:
istream
- The InputStream that contains the Word document.- Throws:
IOException
- If there is an unexpected IOException from the passed in InputStream.
-
HWPFDocument
This constructor loads a Word document from a POIFSFileSystem- Parameters:
pfilesystem
- The POIFSFileSystem that contains the Word document.- Throws:
IOException
- If there is an unexpected IOException from the passed in POIFSFileSystem.
-
HWPFDocument
This constructor loads a Word document from a specific point in a POIFSFileSystem, probably not the default. Used typically to open embeded documents.- Parameters:
directory
- The DirectoryNode that contains the Word document.- Throws:
IOException
- If there is an unexpected IOException from the passed in POIFSFileSystem.
-
-
Method Details
-
getTextTable
- Specified by:
getTextTable
in classHWPFDocumentCore
-
getText
Description copied from class:HWPFDocumentCore
Internal method to access document text- Specified by:
getText
in classHWPFDocumentCore
-
getDocProperties
-
getOverallRange
Description copied from class:HWPFDocumentCore
Returns the range that covers all text in the file, including main text, footnotes, headers and comments- Specified by:
getOverallRange
in classHWPFDocumentCore
-
getRange
Returns the range which covers the whole of the document, but excludes any headers and footers.- Specified by:
getRange
in classHWPFDocumentCore
-
getFootnoteRange
Returns theRange
which covers all the Footnotes.- Returns:
- the
Range
which covers all the Footnotes.
-
getEndnoteRange
Returns theRange
which covers all endnotes.- Returns:
- the
Range
which covers all endnotes.
-
getCommentsRange
Returns theRange
which covers all annotations.- Returns:
- the
Range
which covers all annotations.
-
getMainTextboxRange
Returns theRange
which covers all textboxes.- Returns:
- the
Range
which covers all textboxes.
-
getHeaderStoryRange
Returns the range which covers all "Header Stories". A header story contains a header, footer, end note separators and footnote separators. -
characterLength
public int characterLength()Returns the character length of a document.- Returns:
- the character length of a document
-
getSavedByTable
Gets a reference to the saved -by table, which holds the save history for the document.- Returns:
- the saved-by table.
-
getRevisionMarkAuthorTable
Gets a reference to the revision mark author table, which holds the revision mark authors for the document.- Returns:
- the saved-by table.
-
getPicturesTable
- Returns:
- PicturesTable object, that is able to extract images from this document
-
getEscherRecordHolder
-
getOfficeDrawingsHeaders
-
getOfficeDrawingsMain
-
getBookmarks
- Returns:
- user-friendly interface to access document bookmarks
-
getEndnotes
- Returns:
- user-friendly interface to access document endnotes
-
getFootnotes
- Returns:
- user-friendly interface to access document footnotes
-
getFieldsTables
Deprecated.POI 3.8.- Returns:
- FieldsTables object, that is able to extract fields descriptors from this document
-
getFields
Returns user-friendly interface to access documentField
s- Returns:
- user-friendly interface to access document
Field
s
-
write
Write out the word file that is represented by this class, to the currently openFile
, via the writeablePOIFSFileSystem
it was opened as.This will fail (with an
IllegalStateException
if the Document was opened read-only, opened from anInputStream
instead of a File, or if this is not the root document. For those cases, you must usewrite(OutputStream)
orwrite(File)
to write to a brand new document.- Specified by:
write
in classPOIDocument
- Throws:
IOException
- thrown on errors writing to the file- Since:
- 3.15
-
write
Writes out the word file that is represented by an instance of this class. If theFile
exists, it will be replaced, otherwise a new one will be created- Specified by:
write
in classPOIDocument
- Parameters:
newFile
- The File to write to.- Throws:
IOException
- If there is an unexpected IOException from writing to the File.- Since:
- 3.15 beta 3
-
write
Writes out the word file that is represented by an instance of this class. For better performance when writing to files, usewrite(File)
. Ifstream
has a high cost/latency associated with each written byte, consider wrapping the OutputStream in aBufferedOutputStream
to improve write performance.- Specified by:
write
in classPOIDocument
- Parameters:
out
- The OutputStream to write to.- Throws:
IOException
- If there is an unexpected IOException from the passed in OutputStream.
-
getDataStream
-
getTableStream
-
registerList
-
delete
public void delete(int start, int length)
-