Viewer

Inheritance: java.lang.Object

All Implemented Interfaces: java.io.Closeable

public class Viewer implements Closeable

Represents the main class that controls the document rendering process.

The Viewer class is the entry point for rendering documents using the GroupDocs.Viewer component. It provides methods and options to load documents from various sources, customize the rendering process, and retrieve the rendered output in different formats.

Example usage:


 try (Viewer viewer = new Viewer("source.pdf")) {
     viewer.view(new PngViewOptions("result-page{0}.png"));
 }
 

Constructors

Constructor Description
Viewer(InputStream fileStream) Initializes a new instance of the Viewer class.
Viewer(InputStream fileStream, boolean leaveOpen) Initializes a new instance of the Viewer class.
Viewer(InputStream fileStream, LoadOptions loadOptions) Initializes a new instance of the Viewer class.
Viewer(InputStream fileStream, LoadOptions loadOptions, boolean leaveOpen) Initializes a new instance of the Viewer class.
Viewer(InputStream fileStream, ViewerSettings settings) Initializes a new instance of the Viewer class.
Viewer(InputStream fileStream, ViewerSettings settings, boolean leaveOpen) Initializes a new instance of the Viewer class.
Viewer(InputStream fileStream, LoadOptions loadOptions, ViewerSettings settings) Initializes a new instance of the Viewer class.
Viewer(InputStream fileStream, LoadOptions loadOptions, ViewerSettings settings, boolean leaveOpen) Initializes new instance of Viewer class.
Viewer(URL url) Initializes a new instance of the Viewer class.
Viewer(URL url, LoadOptions loadOptions) Initializes a new instance of the Viewer class.
Viewer(URL url, ViewerSettings settings) Initializes a new instance of the Viewer class.
Viewer(URL url, LoadOptions loadOptions, ViewerSettings settings) Initializes a new instance of the Viewer class.
Viewer(FileReader fileReader, ViewerSettings settings) Initializes a new instance of the Viewer class.
Viewer(FileReader fileReader, LoadOptions loadOptions, ViewerSettings settings) Initializes a new instance of the Viewer class.
Viewer(String filePath) Initializes a new instance of the Viewer class.
Viewer(Path filePath) Initializes a new instance of the Viewer class.
Viewer(String filePath, LoadOptions loadOptions) Initializes a new instance of the Viewer class.
Viewer(Path filePath, LoadOptions loadOptions) Initializes a new instance of the Viewer class.
Viewer(String filePath, ViewerSettings settings) Initializes a new instance of the Viewer class.
Viewer(Path filePath, ViewerSettings settings) Initializes a new instance of the Viewer class.
Viewer(String filePath, LoadOptions loadOptions, ViewerSettings settings) Initializes a new instance of the Viewer class.
Viewer(Path filePath, LoadOptions loadOptions, ViewerSettings settings) Initializes a new instance of the Viewer class.

Fields

Field Description
LOAD_OPTIONS
SETTINGS
FILE_READER
OPTIONS

Methods

Method Description
getViewInfo(ViewInfoOptions options) Returns information about the view and document specific information.
getAttachments() Returns attachments contained by the document.
saveAttachment(Attachment attachment, OutputStream destination) Saves an attachment file to the destination stream.
view(ViewOptions options) Creates a view of all document pages.
view(ViewOptions options, int[] pageNumbers) Creates a view of specific document pages.
getFileInfo() Returns information about the file, such as file type and a flag that indicates if the file is encrypted.
close() Releases the file stream and managed internal resources.

Viewer(InputStream fileStream)

public Viewer(InputStream fileStream)

Initializes a new instance of the Viewer class.

More about file types supported by GroupDocs.Viewer: Document formats supported by GroupDocs.Viewer

Parameters:

Parameter Type Description
fileStream java.io.InputStream The method that returns a readable stream.

Viewer(InputStream fileStream, boolean leaveOpen)

public Viewer(InputStream fileStream, boolean leaveOpen)

Initializes a new instance of the Viewer class.

Learn more

Parameters:

Parameter Type Description
fileStream java.io.InputStream The file stream.
leaveOpen boolean true to leave the stream open after the Viewer object is disposed; otherwise, false.

Viewer(InputStream fileStream, LoadOptions loadOptions)

public Viewer(InputStream fileStream, LoadOptions loadOptions)

Initializes a new instance of the Viewer class.

Learn more

Parameters:

Parameter Type Description
fileStream java.io.InputStream The readable stream.
loadOptions LoadOptions The document load options.

Viewer(InputStream fileStream, LoadOptions loadOptions, boolean leaveOpen)

public Viewer(InputStream fileStream, LoadOptions loadOptions, boolean leaveOpen)

Initializes a new instance of the Viewer class.

Learn more

Parameters:

Parameter Type Description
fileStream java.io.InputStream The file stream.
loadOptions LoadOptions The document load options.
leaveOpen boolean true to leave the stream open after the Viewer object is disposed; otherwise, false.

Viewer(InputStream fileStream, ViewerSettings settings)

public Viewer(InputStream fileStream, ViewerSettings settings)

Initializes a new instance of the Viewer class.

Learn more

Parameters:

Parameter Type Description
fileStream java.io.InputStream The file stream.
settings ViewerSettings The Viewer settings.

Viewer(InputStream fileStream, ViewerSettings settings, boolean leaveOpen)

public Viewer(InputStream fileStream, ViewerSettings settings, boolean leaveOpen)

Initializes a new instance of the Viewer class.

Learn more

Parameters:

Parameter Type Description
fileStream java.io.InputStream The file stream.
settings ViewerSettings The Viewer settings.
leaveOpen boolean true to leave the stream open after the Viewer object is disposed; otherwise, false.

Viewer(InputStream fileStream, LoadOptions loadOptions, ViewerSettings settings)

public Viewer(InputStream fileStream, LoadOptions loadOptions, ViewerSettings settings)

Initializes a new instance of the Viewer class.

Learn more

Parameters:

Parameter Type Description
fileStream java.io.InputStream The file stream.
loadOptions LoadOptions The document load options.
settings ViewerSettings The Viewer settings.

Viewer(InputStream fileStream, LoadOptions loadOptions, ViewerSettings settings, boolean leaveOpen)

public Viewer(InputStream fileStream, LoadOptions loadOptions, ViewerSettings settings, boolean leaveOpen)

Initializes new instance of Viewer class.

Learn more

Parameters:

Parameter Type Description
fileStream java.io.InputStream The file stream.
loadOptions LoadOptions The document load options.
settings ViewerSettings The Viewer settings.
leaveOpen boolean true to leave the stream open after the Viewer object is disposed; otherwise, false.

Viewer(URL url)

public Viewer(URL url)

Initializes a new instance of the Viewer class.

More about file types supported by GroupDocs.Viewer: Document formats supported by GroupDocs.Viewer

Parameters:

Parameter Type Description
url java.net.URL A URL to a file that should be loaded into the Viewer.

Viewer(URL url, LoadOptions loadOptions)

public Viewer(URL url, LoadOptions loadOptions)

Initializes a new instance of the Viewer class.

Learn more

Parameters:

Parameter Type Description
url java.net.URL A URL to a file that should be loaded into the Viewer.
loadOptions LoadOptions The document load options.

Viewer(URL url, ViewerSettings settings)

public Viewer(URL url, ViewerSettings settings)

Initializes a new instance of the Viewer class.

Learn more

Parameters:

Parameter Type Description
url java.net.URL A URL to a file that should be loaded into the Viewer.
settings ViewerSettings The Viewer settings.

Viewer(URL url, LoadOptions loadOptions, ViewerSettings settings)

public Viewer(URL url, LoadOptions loadOptions, ViewerSettings settings)

Initializes a new instance of the Viewer class.

Learn more

Parameters:

Parameter Type Description
url java.net.URL A URL to a file that should be loaded into the Viewer.
loadOptions LoadOptions The document load options.
settings ViewerSettings The Viewer settings.

Viewer(FileReader fileReader, ViewerSettings settings)

public Viewer(FileReader fileReader, ViewerSettings settings)

Initializes a new instance of the Viewer class.

This constructor allows you to create a Viewer object to view a document from a FileReader with the specified ViewerSettings.

Learn more

Parameters:

Parameter Type Description
fileReader FileReader The FileReader containing the document to be loaded into the Viewer.
settings ViewerSettings The ViewerSettings to be applied to the Viewer.

Viewer(FileReader fileReader, LoadOptions loadOptions, ViewerSettings settings)

public Viewer(FileReader fileReader, LoadOptions loadOptions, ViewerSettings settings)

Initializes a new instance of the Viewer class.

Provides functionality to load and view documents using GroupDocs.Viewer.

Note: Ensure that the file reader, load options, and settings are properly configured for accurate document processing.

Parameters:

Parameter Type Description
fileReader FileReader The file reader.
loadOptions LoadOptions The load options.
settings ViewerSettings The Viewer settings.

Viewer(String filePath)

public Viewer(String filePath)

Initializes a new instance of the Viewer class.

Learn more:

Parameters:

Parameter Type Description
filePath java.lang.String The path to the file to render.

Viewer(Path filePath)

public Viewer(Path filePath)

Initializes a new instance of the Viewer class.

Learn more

Parameters:

Parameter Type Description
filePath java.nio.file.Path The path to the file to render.

Viewer(String filePath, LoadOptions loadOptions)

public Viewer(String filePath, LoadOptions loadOptions)

Initializes a new instance of the Viewer class.

Learn more

Parameters:

Parameter Type Description
filePath java.lang.String The path to the file to render.
loadOptions LoadOptions The document load options.

Viewer(Path filePath, LoadOptions loadOptions)

public Viewer(Path filePath, LoadOptions loadOptions)

Initializes a new instance of the Viewer class.

Learn more

Parameters:

Parameter Type Description
filePath java.nio.file.Path The path to the file to render.
loadOptions LoadOptions The document load options.

Viewer(String filePath, ViewerSettings settings)

public Viewer(String filePath, ViewerSettings settings)

Initializes a new instance of the Viewer class.

Learn more

Parameters:

Parameter Type Description
filePath java.lang.String The path to the file to render.
settings ViewerSettings The Viewer settings.

Viewer(Path filePath, ViewerSettings settings)

public Viewer(Path filePath, ViewerSettings settings)

Initializes a new instance of the Viewer class.

Learn more

Parameters:

Parameter Type Description
filePath java.nio.file.Path The path to the file to render.
settings ViewerSettings The Viewer settings.

Viewer(String filePath, LoadOptions loadOptions, ViewerSettings settings)

public Viewer(String filePath, LoadOptions loadOptions, ViewerSettings settings)

Initializes a new instance of the Viewer class.

Learn more

Parameters:

Parameter Type Description
filePath java.lang.String The path to the file to render.
loadOptions LoadOptions The document load options.
settings ViewerSettings The Viewer settings.

Viewer(Path filePath, LoadOptions loadOptions, ViewerSettings settings)

public Viewer(Path filePath, LoadOptions loadOptions, ViewerSettings settings)

Initializes a new instance of the Viewer class.

Learn more

Parameters:

Parameter Type Description
filePath java.nio.file.Path The path to the file to render.
loadOptions LoadOptions The document load options.
settings ViewerSettings The Viewer settings.

LOAD_OPTIONS

public static final String LOAD_OPTIONS

SETTINGS

public static final String SETTINGS

FILE_READER

public static final String FILE_READER

OPTIONS

public static final String OPTIONS

getViewInfo(ViewInfoOptions options)

public final ViewInfo getViewInfo(ViewInfoOptions options)

Returns information about the view and document specific information.

Learn more:

Parameters:

Parameter Type Description
options ViewInfoOptions The view info options.

Returns: ViewInfo - Information about the view and document specific information.

getAttachments()

public final List<Attachment> getAttachments()

Returns attachments contained by the document.

Learn more:

Returns: java.util.List<com.groupdocs.viewer.results.Attachment> - attachments contained by the document.

saveAttachment(Attachment attachment, OutputStream destination)

public void saveAttachment(Attachment attachment, OutputStream destination)

Saves an attachment file to the destination stream.

Learn more:

Parameters:

Parameter Type Description
attachment Attachment The attachment.
destination java.io.OutputStream The writable stream.

view(ViewOptions options)

public final void view(ViewOptions options)

Creates a view of all document pages.

Learn more

Parameters:

Parameter Type Description
options ViewOptions The view options.

view(ViewOptions options, int[] pageNumbers)

public final void view(ViewOptions options, int[] pageNumbers)

Creates a view of specific document pages.

Learn more

Parameters:

Parameter Type Description
options ViewOptions The view options.
pageNumbers int[] The page numbers to view.

getFileInfo()

public FileInfo getFileInfo()

Returns information about the file, such as file type and a flag that indicates if the file is encrypted.

Learn more:

Returns: FileInfo - the file information.

close()

public final void close()

Releases the file stream and managed internal resources.