public class Viewer extends Object implements Closeable
Represents main class that controls document rendering process.
Constructor and Description |
---|
Viewer(FileReader fileReader,
LoadOptions loadOptions,
ViewerSettings settings)
Initializes new instance of
Viewer class. |
Viewer(FileReader fileReader,
ViewerSettings settings)
Initializes new instance of
Viewer class. |
Viewer(InputStream fileStream)
Initializes new instance of
Viewer class. |
Viewer(InputStream fileStream,
boolean leaveOpen)
Initializes new instance of
Viewer class. |
Viewer(InputStream fileStream,
LoadOptions loadOptions)
Initializes new instance of
Viewer class. |
Viewer(InputStream fileStream,
LoadOptions loadOptions,
boolean leaveOpen)
Initializes new instance of
Viewer class. |
Viewer(InputStream inputStream,
LoadOptions loadOptions,
ViewerSettings settings)
Initializes new instance of
Viewer class. |
Viewer(InputStream inputStream,
LoadOptions loadOptions,
ViewerSettings settings,
boolean leaveOpen)
Initializes new instance of
Viewer class. |
Viewer(InputStream inputStream,
ViewerSettings settings)
Initializes new instance of
Viewer class. |
Viewer(InputStream inputStream,
ViewerSettings settings,
boolean leaveOpen)
Initializes new instance of
|
Viewer(Path filePath)
Initializes new instance of
Viewer class. |
Viewer(Path filePath,
LoadOptions loadOptions)
Initializes new instance of
Viewer class. |
Viewer(Path filePath,
LoadOptions loadOptions,
ViewerSettings settings)
Initializes new instance of
Viewer class. |
Viewer(Path filePath,
ViewerSettings settings)
Initializes new instance of
Viewer class. |
Viewer(String filePath)
Initializes new instance of
Viewer class. |
Viewer(String filePath,
LoadOptions loadOptions)
Initializes new instance of
Viewer class. |
Viewer(String filePath,
LoadOptions loadOptions,
ViewerSettings settings)
Initializes new instance of
Viewer class. |
Viewer(String filePath,
ViewerSettings settings)
Initializes new instance of
Viewer class. |
Modifier and Type | Method and Description |
---|---|
static void |
clearTempFiles()
Deprecated.
|
void |
close()
Releases file stream and managed internal resources.
|
List<Attachment> |
getAttachments()
Returns attachments contained by the document.
|
FileInfo |
getFileInfo()
Returns information about file such as file-type and flag that indicates if file is encrypted.
|
ViewInfo |
getViewInfo(ViewInfoOptions options)
Returns information about view and document specific information.
|
void |
saveAttachment(Attachment attachment,
OutputStream destination)
Saves attachment file to destination stream.
|
void |
view(ViewOptions options)
Creates view of all document pages.
|
void |
view(ViewOptions options,
int... pageNumbers)
Creates view of specific document pages.
|
public Viewer(FileReader fileReader, LoadOptions loadOptions, ViewerSettings settings)
Initializes new instance of Viewer
class.
fileReader
- The file reader.loadOptions
- The load options.settings
- The Viewer settings.IllegalArgumentException
- Thrown when fileReader
is null.IllegalArgumentException
- Thrown when loadOptions
is null.IllegalArgumentException
- Thrown when settings
is null.public Viewer(FileReader fileReader, ViewerSettings settings)
Initializes new instance of Viewer
class.
fileReader
- The file readersettings
- The Viewer settings.IllegalArgumentException
- Thrown when fileReader
is null.IllegalArgumentException
- Thrown when settings
is null.public Viewer(InputStream fileStream)
Initializes new instance of Viewer
class.
fileStream
- The method that returns readable stream.IllegalArgumentException
- Thrown when fileStream
is null.public Viewer(InputStream fileStream, boolean leaveOpen)
Initializes new instance of Viewer
class.
fileStream
- The file stream.leaveOpen
- true to leave the stream open after the Viewer object is disposed; otherwise, falsepublic Viewer(InputStream fileStream, LoadOptions loadOptions)
Initializes new instance of Viewer
class.
fileStream
- The readable stream.loadOptions
- The document load options.IllegalArgumentException
- Thrown when fileStream
is null.IllegalArgumentException
- Thrown when loadOptions
is null.public Viewer(InputStream fileStream, LoadOptions loadOptions, boolean leaveOpen)
Initializes new instance of Viewer
class.
fileStream
- The file stream.loadOptions
- The document load options.leaveOpen
- true to leave the stream open after the Viewer object is disposed; otherwise, falsepublic Viewer(InputStream inputStream, LoadOptions loadOptions, ViewerSettings settings)
Initializes new instance of Viewer
class.
inputStream
- The file streamloadOptions
- The document load options.settings
- The Viewer settings.IllegalArgumentException
- Thrown when inputStream
is null.IllegalArgumentException
- Thrown when settings
is null.public Viewer(InputStream inputStream, LoadOptions loadOptions, ViewerSettings settings, boolean leaveOpen)
Initializes new instance of Viewer
class.
inputStream
- The file stream.loadOptions
- The document load options.settings
- The Viewer settings.leaveOpen
- true to leave the stream open after the Viewer object is disposed; otherwise, falsepublic Viewer(InputStream inputStream, ViewerSettings settings)
Initializes new instance of Viewer
class.
inputStream
- The file streamsettings
- The Viewer settings.IllegalArgumentException
- Thrown when inputStream
is null.IllegalArgumentException
- Thrown when settings
is null.public Viewer(InputStream inputStream, ViewerSettings settings, boolean leaveOpen)
inputStream
- The file stream.settings
- The Viewer settings.leaveOpen
- true to leave the stream open after the Viewer object is disposed; otherwise, falsepublic Viewer(Path filePath) throws FileNotFoundException
Initializes new instance of Viewer
class.
filePath
- The path to the file to render.FileNotFoundException
- Thrown when file can not be found or can not be read.IllegalArgumentException
- Thrown when filePath
is null or empty.public Viewer(Path filePath, LoadOptions loadOptions) throws FileNotFoundException
Initializes new instance of Viewer
class.
filePath
- The path to the file to render.loadOptions
- The document load options.FileNotFoundException
- Thrown when file can not be found or can not be read.IllegalArgumentException
- Thrown when filePath
is null or empty.IllegalArgumentException
- Thrown when loadOptions
is null.public Viewer(Path filePath, LoadOptions loadOptions, ViewerSettings settings)
Initializes new instance of Viewer
class.
filePath
- The path to the file to render.loadOptions
- The document load options.settings
- The Viewer settings.IllegalArgumentException
- Thrown when filePath
is null or empty.IllegalArgumentException
- Thrown when loadOptions
is null.IllegalArgumentException
- Thrown when settings
is null.public Viewer(Path filePath, ViewerSettings settings)
Initializes new instance of Viewer
class.
filePath
- The path to the file to render.settings
- The Viewer settings.IllegalArgumentException
- Thrown when filePath
is null or empty.IllegalArgumentException
- Thrown when settings
is null.public Viewer(String filePath) throws FileNotFoundException
Initializes new instance of Viewer
class.
filePath
- The path to the file to render.FileNotFoundException
- Thrown when file can not be found or can not be read.IllegalArgumentException
- Thrown when filePath
is null or empty.public Viewer(String filePath, LoadOptions loadOptions) throws FileNotFoundException
Initializes new instance of Viewer
class.
filePath
- The path to the file to render.loadOptions
- The document load options.FileNotFoundException
- Thrown when file can not be found or can not be read.IllegalArgumentException
- Thrown when filePath
is null or empty.IllegalArgumentException
- Thrown when loadOptions
is null.public Viewer(String filePath, LoadOptions loadOptions, ViewerSettings settings)
Initializes new instance of Viewer
class.
filePath
- The path to the file to render.loadOptions
- The document load options.settings
- The Viewer settings.IllegalArgumentException
- Thrown when filePath
is null or empty.IllegalArgumentException
- Thrown when loadOptions
is null.IllegalArgumentException
- Thrown when settings
is null.public Viewer(String filePath, ViewerSettings settings)
Initializes new instance of Viewer
class.
filePath
- The path to the file to render.settings
- The Viewer settings.IllegalArgumentException
- Thrown when filePath
is null or empty.IllegalArgumentException
- Thrown when settings
is null.@Deprecated public static void clearTempFiles()
Removes temporary files created during rendering.
Deprecated useMemoryCleaner
public final void close()
Releases file stream and managed internal resources.
close
in interface Closeable
close
in interface AutoCloseable
public final List<Attachment> getAttachments() throws PasswordRequiredException, IncorrectPasswordException
Returns attachments contained by the document.
Learn morePasswordRequiredException
- Thrown when password is required to open
the document.IncorrectPasswordException
- Thrown when password that was specified is
incorrect.public FileInfo getFileInfo()
public final ViewInfo getViewInfo(ViewInfoOptions options) throws IllegalArgumentException, PasswordRequiredException, IncorrectPasswordException
Returns information about view and document specific information.
Learn moreoptions
- The view info options.IllegalArgumentException
- Thrown when options
is null.PasswordRequiredException
- Thrown when password is required to open
the document.IncorrectPasswordException
- Thrown when password that was specified is
incorrect.public void saveAttachment(Attachment attachment, OutputStream destination)
Saves attachment file to destination stream.
Learn moreattachment
- The attachment.destination
- The writable stream.IllegalArgumentException
- Thrown when attachmentId
is null or empty.IllegalArgumentException
- Thrown when destination
is null.PasswordRequiredException
- Thrown when password is required to open the document.IncorrectPasswordException
- Thrown when password that was specified is incorrect.GroupDocsViewerException
- Thrown when attachment could not be found.public final void view(ViewOptions options)
Creates view of all document pages.
Learn moreoptions
- The view options.IllegalArgumentException
- Thrown when options
is null.PasswordRequiredException
- Thrown when password is required to open the document.IncorrectPasswordException
- Thrown when password that was specified is incorrect.GroupDocsViewerException
- Thrown when attachment could not be found.public final void view(ViewOptions options, int... pageNumbers)
Creates view of specific document pages.
Learn moreoptions
- The view options.pageNumbers
- The page numbers to view.IllegalArgumentException
- Thrown when options
is null.IllegalArgumentException
- Thrown when pageNumbers
is null or empty.PasswordRequiredException
- Thrown when password is required to open the document.IncorrectPasswordException
- Thrown when password that was specified is incorrect.GroupDocsViewerException
- Thrown when attachment could not be found.