PdfViewOptions

Inheritance: java.lang.Object, com.groupdocs.viewer.options.BaseViewOptions, com.groupdocs.viewer.options.ViewOptions

public class PdfViewOptions extends ViewOptions

Provides options for rendering documents into PDF format.

The PdfViewOptions class encapsulates additional settings and parameters that can be used to control the rendering of documents into PDF format in the GroupDocs.Viewer component.

Example usage:


 PdfViewOptions pdfViewOptions = new PdfViewOptions();
 pdfViewOptions.setImageHeight(256);
 pdfViewOptions.setImageWidth(128);
 pdfViewOptions.setDefaultFontName("font-name");

 try (Viewer viewer = new Viewer("document.pdf")) {
     viewer.view(pdfViewOptions);
     // Use the viewer object for further operations
 }
 

Constructors

Constructor Description
PdfViewOptions(CreateFileStream createFileStream) Initializes a new instance of the PdfViewOptions class.
PdfViewOptions(CreateFileStream createFileStream, ReleaseFileStream releaseFileStream) Initializes a new instance of the PdfViewOptions class.
PdfViewOptions(FileStreamFactory fileStreamFactory) Initializes a new instance of the PdfViewOptions class.
PdfViewOptions() Initializes a new instance of the PdfViewOptions class with default settings.
PdfViewOptions(String outputFilePath) Initializes a new instance of the PdfViewOptions class.
PdfViewOptions(Path outputFilePath) Initializes a new instance of the PdfViewOptions class.

Methods

Method Description
getJpgQuality() Retrieves the quality of the JPG images contained by the output PDF document.
setJpgQuality(int value) Sets the quality of the JPG images contained by the output PDF document.
getImageMaxWidth() Retrieves the maximum width of an output image in pixels.
setImageMaxWidth(int imageMaxWidth) Sets the maximum width of an output image in pixels.
getImageMaxHeight() Retrieves the maximum height of an output image in pixels.
setImageMaxHeight(int imageMaxHeight) Sets the maximum height of an output image in pixels.
getImageWidth() Retrieves the width of the output image in pixels.
setImageWidth(int imageWidth) Sets the width of the output image in pixels.
getImageHeight() Retrieves the height of the output image in pixels.
setImageHeight(int imageHeight) Sets the height of the output image in pixels.
getSecurity() Retrieves the security options for the output PDF document.
setSecurity(Security value) Sets the security options for the output PDF document.
isOptimize() Reduce output file size by excluding common fonts like Times New Roman and Arial, and applying other optimization techniques.
setOptimize(boolean optimize) Reduce output file size by excluding common fonts like Times New Roman and Arial, and applying other optimization techniques.
getDocumentSavingCallback() Retrieves the callback used to estimate the progress of saving a Words or Email document.
setDocumentSavingCallback(IDocumentSavingCallback documentSavingCallback) Sets the callback used to estimate the progress of saving a Words or Email document.

PdfViewOptions(CreateFileStream createFileStream)

public PdfViewOptions(CreateFileStream createFileStream)

Initializes a new instance of the PdfViewOptions class.

Parameters:

Parameter Type Description
createFileStream CreateFileStream

PdfViewOptions(CreateFileStream createFileStream, ReleaseFileStream releaseFileStream)

public PdfViewOptions(CreateFileStream createFileStream, ReleaseFileStream releaseFileStream)

Initializes a new instance of the PdfViewOptions class.

Parameters:

Parameter Type Description
createFileStream CreateFileStream The method used to instantiate the stream for writing the output file data.
releaseFileStream ReleaseFileStream The method used to release the stream created by the createFileStream method.

PdfViewOptions(FileStreamFactory fileStreamFactory)

public PdfViewOptions(FileStreamFactory fileStreamFactory)

Initializes a new instance of the PdfViewOptions class.

Parameters:

Parameter Type Description
fileStreamFactory FileStreamFactory The factory that implements methods for creating and releasing the output file stream.

PdfViewOptions()

public PdfViewOptions()

Initializes a new instance of the PdfViewOptions class with default settings.

This constructor creates a new PdfViewOptions object with “output.pdf” as the file path format for the output file. The output file will be placed into the current working directory of the application.

PdfViewOptions(String outputFilePath)

public PdfViewOptions(String outputFilePath)

Initializes a new instance of the PdfViewOptions class.

This constructor creates a new PdfViewOptions object with the specified outputFilePath parameter representing the path for the output PDF file.

Parameters:

Parameter Type Description
outputFilePath java.lang.String The path for the output PDF file.

PdfViewOptions(Path outputFilePath)

public PdfViewOptions(Path outputFilePath)

Initializes a new instance of the PdfViewOptions class.

Parameters:

Parameter Type Description
outputFilePath java.nio.file.Path The path for the output PDF file.

getJpgQuality()

public final int getJpgQuality()

Retrieves the quality of the JPG images contained by the output PDF document. The JPG quality determines the level of compression applied to the images in the PDF document.

Note: Valid values range from 1 to 100, where 1 represents the lowest quality and 100 represents the highest quality.

Returns: int - the quality of the JPG images in the output PDF document.

setJpgQuality(int value)

public final void setJpgQuality(int value)

Sets the quality of the JPG images contained by the output PDF document. The JPG quality determines the level of compression applied to the images in the PDF document.

Note: Valid values range from 1 to 100, where 1 represents the lowest quality and 100 represents the highest quality.

Parameters:

Parameter Type Description
value int The quality of the JPG images in the output PDF document.

getImageMaxWidth()

public int getImageMaxWidth()

Retrieves the maximum width of an output image in pixels. This parameter applies only when converting a single image to HTML.

Returns: int - the maximum width of the output image in pixels.

setImageMaxWidth(int imageMaxWidth)

public void setImageMaxWidth(int imageMaxWidth)

Sets the maximum width of an output image in pixels. This parameter applies only when converting a single image to HTML.

Parameters:

Parameter Type Description
imageMaxWidth int The maximum width of the output image in pixels.

getImageMaxHeight()

public int getImageMaxHeight()

Retrieves the maximum height of an output image in pixels. This parameter applies only when converting a single image to HTML.

Returns: int - the maximum height of the output image in pixels.

setImageMaxHeight(int imageMaxHeight)

public void setImageMaxHeight(int imageMaxHeight)

Sets the maximum height of an output image in pixels. This parameter applies only when converting a single image to HTML.

Parameters:

Parameter Type Description
imageMaxHeight int The maximum height of the output image in pixels.

getImageWidth()

public int getImageWidth()

Retrieves the width of the output image in pixels. This parameter applies only when converting a single image to HTML.

Returns: int - the width of the output image in pixels.

setImageWidth(int imageWidth)

public void setImageWidth(int imageWidth)

Sets the width of the output image in pixels. This parameter applies only when converting a single image to HTML.

Parameters:

Parameter Type Description
imageWidth int The width of the output image in pixels.

getImageHeight()

public int getImageHeight()

Retrieves the height of the output image in pixels. This parameter applies only when converting a single image to HTML.

Returns: int - the height of the output image in pixels.

setImageHeight(int imageHeight)

public void setImageHeight(int imageHeight)

Sets the height of the output image in pixels. This parameter applies only when converting a single image to HTML.

Parameters:

Parameter Type Description
imageHeight int The height of the output image in pixels.

getSecurity()

public final Security getSecurity()

Retrieves the security options for the output PDF document.

Returns: Security - the security options for the output PDF document.

setSecurity(Security value)

public final void setSecurity(Security value)

Sets the security options for the output PDF document.

Parameters:

Parameter Type Description
value Security The security options for the output PDF document.

isOptimize()

public boolean isOptimize()

Reduce output file size by excluding common fonts like Times New Roman and Arial, and applying other optimization techniques.

In version 24.2 this option is supported for Spreadsheet file formats only.

Learn more how to export Excel and Apple Numbers spreadsheets to PDF

Example:

try (Viewer viewer = new Viewer("employees.xlsx")) {
     PdfViewOptions viewOptions = new PdfViewOptions();
     viewOptions.setOptimize(true);

     viewer.view(viewOptions);
 }

Returns: boolean

setOptimize(boolean optimize)

public void setOptimize(boolean optimize)

Reduce output file size by excluding common fonts like Times New Roman and Arial, and applying other optimization techniques.

In version 24.2 this option is supported for Spreadsheet file formats only.

Learn more how to export Excel and Apple Numbers spreadsheets to PDF

Example:

try (Viewer viewer = new Viewer("employees.xlsx")) {
     PdfViewOptions viewOptions = new PdfViewOptions();
     viewOptions.setOptimize(true);

     viewer.view(viewOptions);
 }

Parameters:

Parameter Type Description
optimize boolean

getDocumentSavingCallback()

public IDocumentSavingCallback getDocumentSavingCallback()

Retrieves the callback used to estimate the progress of saving a Words or Email document.

Returns: com.groupdocs.viewer.domain.documents.converting.tohtml.utils.IDocumentSavingCallback - the callback to estimate the document saving progress.

setDocumentSavingCallback(IDocumentSavingCallback documentSavingCallback)

public void setDocumentSavingCallback(IDocumentSavingCallback documentSavingCallback)

Sets the callback used to estimate the progress of saving a Words or Email document.

Parameters:

Parameter Type Description
documentSavingCallback com.groupdocs.viewer.domain.documents.converting.tohtml.utils.IDocumentSavingCallback The callback to estimate the document saving progress.