PdfExportOptionsBase Class
The base class for PDF export options.
Declaration
public abstract class PdfExportOptionsBase extends JavaObject
Remarks
The PdfExportOptions class derives from the PdfExportOptionsBase class. To customize PDF export settings, pass a PdfExportOptions object to the Presentation.exportToPdf(stream, options) method.
Refer to the following help topic for additional information: Export PowerPoint Presentations to PDF.
Inherited Members
Inheritance
PdfExportOptionsBase()
Initializes a new instance of the PdfExportOptionsBase class.
Declaration
public PdfExportOptionsBase()
Methods
getAttachments() Method
Returns files to attach to the exported PDF document.
Declaration
public Collection<Attachment> getAttachments()
Returns
| Type | Description |
|---|---|
| java.util.Collection<Attachment> | A collection of files to attach to the exported PDF document. |
Remarks
Add Attachment objects to the collection to embed files (for example, source data) in the exported PDF document.
getConvertImagesToJpeg() Method
Returns whether to convert bitmap images to JPEG format.
Declaration
public boolean getConvertImagesToJpeg()
Returns
| Type | Description |
|---|---|
| boolean |
|
getDocumentOptions() Method
Returns PDF document properties (for example, the title and author).
Declaration
public DocumentExportOptions getDocumentOptions()
Returns
| Type | Description |
|---|---|
| DocumentExportOptions | PDF document properties. |
Remarks
The DocumentExportOptions object specifies the author, title, subject, keywords, producer, and application name of the exported PDF document.
The setMetadataExportMode(MetadataExportMode value) method specifies whether the PDF document gets the author, title, subject, and keywords from PDF document options, from presentation document properties (getDocumentProperties()), or from both sources.
Example: Specify PDF Document Properties for an Exported Presentation
The following code snippet exports a PowerPoint presentation to PDF and sets the PDF document metadata, including the author, application, keywords, producer, subject, and title:
import com.devexpress.docs.presentation.*;
import com.devexpress.docs.presentation.exports.PdfExportOptions;
import java.io.FileOutputStream;
import java.nio.file.*;
public class Main {
public static void main(String[] args) throws Exception {
try(Presentation presentation =
new Presentation(Files.readAllBytes(Path.of("Sample.pptx")))) {
Path outputDir = Path.of("output");
Files.createDirectories(outputDir);
try (FileOutputStream exportStream = new FileOutputStream(
outputDir.resolve("presentation.pdf").toFile())) {
PdfExportOptions exportOptions = new PdfExportOptions();
exportOptions.getDocumentOptions().setAuthor("Simon Peacock");
exportOptions.getDocumentOptions().setApplication("DevExpress Presentation API");
exportOptions.getDocumentOptions().setKeywords("Presentation, DevExpress, Exported, PDF");
exportOptions.getDocumentOptions().setProducer("Developer Express Inc., 26.1.4");
exportOptions.getDocumentOptions().setSubject("Test Presentation");
exportOptions.getDocumentOptions().setTitle("Presentation Title");
presentation.exportToPdf(exportStream, exportOptions);
}
}
}
}
getEncryptionOptions() Method
Returns encryption options for the exported PDF document.
Declaration
public EncryptionOptions getEncryptionOptions()
Returns
| Type | Description |
|---|---|
| EncryptionOptions | Encryption options, or |
getImageQuality() Method
Returns the quality of JPEG images in the exported PDF document.
Declaration
public ImageQuality getImageQuality()
Returns
| Type | Description |
|---|---|
| ImageQuality | JPEG image quality. |
getMetadataExportMode() Method
Returns the source of metadata for the exported PDF document.
Declaration
public MetadataExportMode getMetadataExportMode()
Returns
| Type | Description |
|---|---|
| MetadataExportMode | The metadata export mode. |
getNonEmbeddedFonts() Method
Returns names of fonts that the export does not embed in the PDF document.
Declaration
public String getNonEmbeddedFonts()
Returns
| Type | Description |
|---|---|
| String | Font names separated by semicolons, or |
getRasterizationResolution() Method
Returns the resolution for images that the export rasterizes.
Declaration
public int getRasterizationResolution()
Returns
| Type | Description |
|---|---|
| int | The resolution in dots per inch (DPI). |
getRasterizeImages() Method
Returns whether to rasterize vector images during export.
Declaration
public boolean getRasterizeImages()
Returns
| Type | Description |
|---|---|
| boolean |
|
getShowPrintDialogOnOpen() Method
Returns whether a PDF viewer opens the Print dialog when a user opens the exported document.
Declaration
public boolean getShowPrintDialogOnOpen()
Returns
| Type | Description |
|---|---|
| boolean |
|
getSignatureOptions() Method
Returns digital signature options for the exported PDF document.
Declaration
public SignatureOptions getSignatureOptions()
Returns
| Type | Description |
|---|---|
| SignatureOptions | Digital signature options. |
setConvertImagesToJpeg(boolean value) Method
Sets whether to convert bitmap images to JPEG format.
Declaration
public void setConvertImagesToJpeg(boolean value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | boolean |
|
Remarks
Call the setConvertImagesToJpeg(true) method to reduce the PDF file size. The setImageQuality(ImageQuality value) method specifies the JPEG quality. If the quality is lower than ImageQuality.HIGHEST, the export keeps a JPEG image only if the JPEG image is smaller than the original image.
The export does not convert vector images (metafiles and SVG images) to JPEG. To convert vector images to bitmaps, call the setRasterizeImages(true) method.
setEncryptionOptions(EncryptionOptions value) Method
Sets encryption options for the exported PDF document.
Declaration
public void setEncryptionOptions(EncryptionOptions value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | EncryptionOptions | Encryption options, or |
Remarks
If you do not call the setEncryptionOptions(value) method, the export does not encrypt the PDF document. To encrypt the document, create an EncryptionOptions object and pass it to the setEncryptionOptions(value) method. The EncryptionOptions(ownerPassword, userPassword) constructor specifies passwords.
The export supports the following combinations of EncryptionOptions.getInteractivityPermissions() and EncryptionOptions.getModificationPermissions() values:
| Interactivity Permissions | Modification Permissions |
|---|---|
NOT_ALLOWED |
NOT_ALLOWED |
FORM_FILL_AND_SIGN |
NOT_ALLOWED |
ALLOWED |
NOT_ALLOWED |
NOT_ALLOWED |
DOCUMENT_ASSEMBLING |
ALLOWED |
ALLOWED |
For other combinations, Presentation.exportToPdf methods throw a JavaException with the “Cannot export the document to PDF.” message.
setImageQuality(ImageQuality value) Method
Sets the quality of JPEG images in the exported PDF document.
Declaration
public void setImageQuality(ImageQuality value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | ImageQuality | JPEG image quality. |
Remarks
Note
The JPEG image quality takes effect when you call the setConvertImagesToJpeg(true) method.
The setImageQuality(value) method accepts the following values:
| Value | Description |
|---|---|
| LOWEST | The lowest image quality level (10%). |
| LOW | A low image quality level (25%). |
| MEDIUM | A medium image quality level (50%). |
| HIGH | A high image quality level (75%). |
| HIGHEST | The highest image quality level (100%). |
If you do not call the setImageQuality(value) method, the API uses the ImageQuality.HIGHEST value.
setMetadataExportMode(MetadataExportMode value) Method
Sets the source of metadata for the exported PDF document.
Declaration
public void setMetadataExportMode(MetadataExportMode value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | MetadataExportMode | The metadata export mode. |
Remarks
The exported PDF document can get the author, title, subject, and keywords from the following sources:
- PDF document options (getDocumentOptions())
- Presentation document properties (getDocumentProperties())
Call the setMetadataExportMode(value) method to specify the source for these values:
| Value | Description |
|---|---|
| MERGE | Merges metadata from the source document and PDF document options. |
| SOURCE_DOCUMENT_PROPERTIES | Uses metadata from source document properties. |
| PDF_DOCUMENT_OPTIONS | Uses metadata from PDF document options. |
If you do not call the setMetadataExportMode(value) method, the API uses the MetadataExportMode.MERGE value. In this mode, PDF document options take precedence. If a PDF document option is empty, the exported PDF document gets the value from presentation document properties.
The exported PDF document always gets the producer and application name from PDF document options.
setNonEmbeddedFonts(String value) Method
Sets names of fonts that the export does not embed in the PDF document.
Declaration
public void setNonEmbeddedFonts(String value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | String | Font names separated by semicolons, or |
Remarks
If you do not call the setNonEmbeddedFonts(value) method or if you pass an empty string, the export embeds all fonts.
Separate font names with semicolons (for example, Arial;Calibri). Font names are case-sensitive. The export ignores spaces in font names.
To exclude a single font style, add the style name after a comma (Arial,Bold, Arial,Italic, or Arial,BoldItalic).
To embed no fonts, call the setNonEmbeddedFonts("*") method.
Non-embedded fonts reduce the PDF file size. If a user machine does not have a non-embedded font, the PDF viewer substitutes another font.
Example: Specify Non-Embedded Fonts for a Presentation Exported to PDF
The following code snippet exports a presentation to PDF and does not embed the Helvetica, Aptos, and Tahoma fonts:
import java.io.*;
import java.nio.file.*;
import com.devexpress.docs.presentation.*;
import com.devexpress.docs.presentation.exports.*;
public class Main {
public static void main(String[] args) throws Exception {
Files.createDirectories(Path.of("output"));
try (InputStream input = Files.newInputStream(Path.of("Document.pptx"));
Presentation presentation = new Presentation(input);
OutputStream output = Files.newOutputStream(Path.of("output", "Document.pdf"))) {
PdfExportOptions options = new PdfExportOptions();
options.setNonEmbeddedFonts("Helvetica;Aptos;Tahoma");
presentation.exportToPdf(output, options);
}
}
}
setRasterizationResolution(int value) Method
Sets the resolution for images that the export rasterizes.
Declaration
public void setRasterizationResolution(int value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | int | The resolution in dots per inch (DPI). |
Remarks
The export applies the rasterization resolution in the following instances:
- You call the setRasterizeImages(true) method. The export converts vector images to bitmaps at the specified resolution.
- The export cannot render a metafile as vector graphics. The export converts the metafile to a bitmap at the specified resolution or the metafile’s resolution, whichever is higher.
If you do not call the setRasterizationResolution(value) method, the API uses 96 DPI.
setRasterizeImages(boolean value) Method
Sets whether to rasterize vector images during export.
Declaration
public void setRasterizeImages(boolean value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | boolean |
|
Remarks
If you call the setRasterizeImages(true) method, the export converts vector images (metafiles and SVG images) to bitmaps. The setRasterizationResolution(int value) method specifies the bitmap resolution.
setShowPrintDialogOnOpen(boolean value) Method
Sets whether a PDF viewer opens the Print dialog when a user opens the exported document.
Declaration
public void setShowPrintDialogOnOpen(boolean value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | boolean |
|
Remarks
If you call the setShowPrintDialogOnOpen(true) method, the export adds a document-level script to the PDF document. The script opens the Print dialog when a PDF viewer opens the document. PDF viewers that do not run JavaScript (for example, most web browsers) ignore this setting.