PdfOptions
Inheritance: java.lang.Object, com.aspose.slides.SaveOptions
All Implemented Interfaces: com.aspose.slides.IPdfOptions
public class PdfOptions extends SaveOptions implements IPdfOptions
Provides options that control how a presentation is saved in Pdf format.
The following example shows how to convert PowerPoint to PDF with custom options. Presentation pres = new Presentation("PowerPoint.pptx"); try { // Instantiates the PdfOptions class PdfOptions pdfOptions = new PdfOptions(); // Sets the Jpeg quality pdfOptions.setJpegQuality((byte)90); // Sets the behavior for metafiles pdfOptions.setSaveMetafilesAsPng(true); // Sets the text compression level pdfOptions.setTextCompression(PdfTextCompression.Flate); // Defines the PDF standard pdfOptions.setCompliance(PdfCompliance.Pdf15); // Saves the presentation as a PDF pres.save("PowerPoint-to-PDF.pdf", SaveFormat.Pdf, pdfOptions); } finally { if (pres != null) pres.dispose(); } The following example shows how to convert PowerPoint to PDF with hidden slides. // Instantiates a Presentation class that represents a PowerPoint file Presentation pres = new Presentation("PowerPoint.pptx"); try { // Instantiates the PdfOptions class PdfOptions pdfOptions = new PdfOptions(); // Adds hidden slides pdfOptions.setShowHiddenSlides(true); // Saves the presentation as a PDF pres.save("PowerPoint-to-PDF.pdf", SaveFormat.Pdf, pdfOptions); } finally { if (pres != null) pres.dispose(); } The following example shows how to convert PowerPoint to password protected PDF. // Instantiates a Presentation object that represents a PowerPoint file Presentation pres = new Presentation("PowerPoint.pptx"); try { // Instantiates the PdfOptions class PdfOptions pdfOptions = new PdfOptions(); // Sets PDF password and access permissions pdfOptions.setPassword("password"); pdfOptions.setAccessPermissions(PdfAccessPermissions.PrintDocument | PdfAccessPermissions.HighQualityPrint); // Saves the presentation as a PDF pres.save("PPTX-to-PDF.pdf", SaveFormat.Pdf, pdfOptions); } finally { if (pres != null) pres.dispose(); } The following example shows how to convert PowerPoint to PDF with notes. // Instantiate a Presentation object that represents a presentation file Presentation pres = new Presentation("SelectedSlides.pptx"); try { Presentation auxPres = new Presentation(); try { ISlide slide = pres.getSlides().get_Item(0); auxPres.getSlides().insertClone(0, slide); // Setting Slide Type and Size auxPres.getSlideSize().setSize(612F, 792F, SlideSizeScaleType.EnsureFit); PdfOptions pdfOptions = new PdfOptions(); pdfOptions.getNotesCommentsLayouting().setNotesPosition(NotesPositions.BottomFull); auxPres.save("PDFnotes_out.pdf", SaveFormat.Pdf, pdfOptions); } finally { if (auxPres != null) auxPres.dispose(); } } finally { if (pres != null) pres.dispose(); }
Constructors
Constructor | Description |
---|---|
PdfOptions() | Default constructor. |
Methods
Method | Description |
---|---|
getSlidesLayoutOptions() | Gets or sets the mode in which slides are placed on the page when exporting a presentation ISlidesLayoutOptions. |
setSlidesLayoutOptions(ISlidesLayoutOptions value) | Gets or sets the mode in which slides are placed on the page when exporting a presentation ISlidesLayoutOptions. |
getInkOptions() | Provides options that control the look of Ink objects in exported document. |
getNotesCommentsLayouting() | Provides options that control how notes and comments is placed in exported document. |
getShowHiddenSlides() | Specifies whether the generated document should include hidden slides or not. |
setShowHiddenSlides(boolean value) | Specifies whether the generated document should include hidden slides or not. |
getTextCompression() | Specifies compression type to be used for all textual content in the document. |
setTextCompression(int value) | Specifies compression type to be used for all textual content in the document. |
getBestImagesCompressionRatio() | Indicates if the most effective compression (instead of the default one) for each image must be selected automatically. |
setBestImagesCompressionRatio(boolean value) | Indicates if the most effective compression (instead of the default one) for each image must be selected automatically. |
getEmbedTrueTypeFontsForASCII() | Determines if Aspose.Slides will embed common fonts for ASCII (33..127 code range) text. |
setEmbedTrueTypeFontsForASCII(boolean value) | Determines if Aspose.Slides will embed common fonts for ASCII (33..127 code range) text. |
getAdditionalCommonFontFamilies() | Returns or sets an array of user-defined names of font families which Aspose.Slides should consider common. |
setAdditionalCommonFontFamilies(String[] value) | Returns or sets an array of user-defined names of font families which Aspose.Slides should consider common. |
getEmbedFullFonts() | Determines if all characters of font should be embedded or only used subset. |
setEmbedFullFonts(boolean value) | Determines if all characters of font should be embedded or only used subset. |
getRasterizeUnsupportedFontStyles() | Indicates whether text should be rasterized as a bitmap and saved to PDF when the font does not support bold styling. |
setRasterizeUnsupportedFontStyles(boolean value) | Indicates whether text should be rasterized as a bitmap and saved to PDF when the font does not support bold styling. |
getJpegQuality() | Returns or sets a value determining the quality of the JPEG images inside PDF document. |
setJpegQuality(byte value) | Returns or sets a value determining the quality of the JPEG images inside PDF document. |
getCompliance() | Desired conformance level for generated PDF document. |
setCompliance(int value) | Desired conformance level for generated PDF document. |
getPassword() | Setting user password to protect the PDF document. |
setPassword(String value) | Setting user password to protect the PDF document. |
getAccessPermissions() | Contains a set of flags specifying which access permissions should be granted when the document is opened with user access. |
setAccessPermissions(int value) | Contains a set of flags specifying which access permissions should be granted when the document is opened with user access. |
getSaveMetafilesAsPng() | True to convert all metafiles used in a presentation to the PNG images. |
setSaveMetafilesAsPng(boolean value) | True to convert all metafiles used in a presentation to the PNG images. |
getSufficientResolution() | Returns or sets a value determining resolution of images inside PDF document. |
setSufficientResolution(float value) | Returns or sets a value determining resolution of images inside PDF document. |
getDrawSlidesFrame() | True to draw black frame around each slide. |
setDrawSlidesFrame(boolean value) | True to draw black frame around each slide. |
getImageTransparentColor() | Gets or sets the image transparent color. |
setImageTransparentColor(Color value) | Gets or sets the image transparent color. |
getApplyImageTransparent() | Applies the specified transparent color to an image if true. |
setApplyImageTransparent(boolean value) | Applies the specified transparent color to an image if true. |
getIncludeOleData() | True to convert all OLE data from the presentation to embedded files in the resulting PDF. |
setIncludeOleData(boolean value) | True to convert all OLE data from the presentation to embedded files in the resulting PDF. |
PdfOptions()
public PdfOptions()
Default constructor.
getSlidesLayoutOptions()
public final ISlidesLayoutOptions getSlidesLayoutOptions()
Gets or sets the mode in which slides are placed on the page when exporting a presentation ISlidesLayoutOptions.
Example: Presentation pres = new Presentation("pres.pptx"); try { PdfOptions options = new PdfOptions(); HandoutLayoutingOptions slidesLayoutOptions = new HandoutLayoutingOptions(); slidesLayoutOptions.setHandout(HandoutType.Handouts4Horizontal); options.setSlidesLayoutOptions(slidesLayoutOptions); pres.save("pres.pdf", SaveFormat.Pdf, options); } finally { if (pres != null) pres.dispose(); }
Returns: ISlidesLayoutOptions
setSlidesLayoutOptions(ISlidesLayoutOptions value)
public final void setSlidesLayoutOptions(ISlidesLayoutOptions value)
Gets or sets the mode in which slides are placed on the page when exporting a presentation ISlidesLayoutOptions.
Example: Presentation pres = new Presentation("pres.pptx"); try { PdfOptions options = new PdfOptions(); HandoutLayoutingOptions slidesLayoutOptions = new HandoutLayoutingOptions(); slidesLayoutOptions.setHandout(HandoutType.Handouts4Horizontal); options.setSlidesLayoutOptions(slidesLayoutOptions); pres.save("pres.pdf", SaveFormat.Pdf, options); } finally { if (pres != null) pres.dispose(); }
Parameters:
Parameter | Type | Description |
---|---|---|
value | ISlidesLayoutOptions |
getInkOptions()
public final IInkOptions getInkOptions()
Provides options that control the look of Ink objects in exported document. Read-only IInkOptions
Returns: IInkOptions
getNotesCommentsLayouting()
public final INotesCommentsLayoutingOptions getNotesCommentsLayouting()
Provides options that control how notes and comments is placed in exported document.
Returns: INotesCommentsLayoutingOptions
getShowHiddenSlides()
public final boolean getShowHiddenSlides()
Specifies whether the generated document should include hidden slides or not. Default is false.
Returns: boolean
setShowHiddenSlides(boolean value)
public final void setShowHiddenSlides(boolean value)
Specifies whether the generated document should include hidden slides or not. Default is false.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
getTextCompression()
public final int getTextCompression()
Specifies compression type to be used for all textual content in the document. Read/write PdfTextCompression.
Default is PdfTextCompression.Flate.
Returns: int
setTextCompression(int value)
public final void setTextCompression(int value)
Specifies compression type to be used for all textual content in the document. Read/write PdfTextCompression.
Default is PdfTextCompression.Flate.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
getBestImagesCompressionRatio()
public final boolean getBestImagesCompressionRatio()
Indicates if the most effective compression (instead of the default one) for each image must be selected automatically. If set to true, for every image in presentation the most appropriate compression algorithm will be chosen, what will lead to the smaller size of the resulting PDF document.
Best image compression ratio selection is computationally expensive and takes an additional amount of RAM, and this option is false by default.
Default is false.
Returns: boolean
setBestImagesCompressionRatio(boolean value)
public final void setBestImagesCompressionRatio(boolean value)
Indicates if the most effective compression (instead of the default one) for each image must be selected automatically. If set to true, for every image in presentation the most appropriate compression algorithm will be chosen, what will lead to the smaller size of the resulting PDF document.
Best image compression ratio selection is computationally expensive and takes an additional amount of RAM, and this option is false by default.
Default is false.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
getEmbedTrueTypeFontsForASCII()
public final boolean getEmbedTrueTypeFontsForASCII()
Determines if Aspose.Slides will embed common fonts for ASCII (33..127 code range) text. Fonts for character codes greater than 127 are always embedded. Common fonts list includes PDF’s base 14 fonts and additional user specified fonts. Read/write boolean.
Default is true.
Returns: boolean
setEmbedTrueTypeFontsForASCII(boolean value)
public final void setEmbedTrueTypeFontsForASCII(boolean value)
Determines if Aspose.Slides will embed common fonts for ASCII (33..127 code range) text. Fonts for character codes greater than 127 are always embedded. Common fonts list includes PDF’s base 14 fonts and additional user specified fonts. Read/write boolean.
Default is true.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
getAdditionalCommonFontFamilies()
public final String[] getAdditionalCommonFontFamilies()
Returns or sets an array of user-defined names of font families which Aspose.Slides should consider common. Read/write String[].
Returns: java.lang.String[]
setAdditionalCommonFontFamilies(String[] value)
public final void setAdditionalCommonFontFamilies(String[] value)
Returns or sets an array of user-defined names of font families which Aspose.Slides should consider common. Read/write String[].
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String[] |
getEmbedFullFonts()
public final boolean getEmbedFullFonts()
Determines if all characters of font should be embedded or only used subset. Read/write boolean.
Default is false.
Returns: boolean
setEmbedFullFonts(boolean value)
public final void setEmbedFullFonts(boolean value)
Determines if all characters of font should be embedded or only used subset. Read/write boolean.
Default is false.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
getRasterizeUnsupportedFontStyles()
public final boolean getRasterizeUnsupportedFontStyles()
Indicates whether text should be rasterized as a bitmap and saved to PDF when the font does not support bold styling. This approach can enhance the quality of text in the resulting PDF for certain fonts. Read/write boolean.
Default is false.
Returns: boolean
setRasterizeUnsupportedFontStyles(boolean value)
public final void setRasterizeUnsupportedFontStyles(boolean value)
Indicates whether text should be rasterized as a bitmap and saved to PDF when the font does not support bold styling. This approach can enhance the quality of text in the resulting PDF for certain fonts. Read/write boolean.
Default is false.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
getJpegQuality()
public final byte getJpegQuality()
Returns or sets a value determining the quality of the JPEG images inside PDF document. Read/write byte.
Has effect only when a document contains JPEG images.
Use this property to get or set the quality of the images inside a document when saving in PDF format. The value may vary from 0 to 100 where 0 means worst quality but maximum compression and 100 means best quality but minimum compression.
The default value is 100.
Returns: byte
setJpegQuality(byte value)
public final void setJpegQuality(byte value)
Returns or sets a value determining the quality of the JPEG images inside PDF document. Read/write byte.
Has effect only when a document contains JPEG images.
Use this property to get or set the quality of the images inside a document when saving in PDF format. The value may vary from 0 to 100 where 0 means worst quality but maximum compression and 100 means best quality but minimum compression.
The default value is 100.
Parameters:
Parameter | Type | Description |
---|---|---|
value | byte |
getCompliance()
public final int getCompliance()
Desired conformance level for generated PDF document. Read/write PdfCompliance.
Default is PdfCompliance.Pdf17.
Returns: int
setCompliance(int value)
public final void setCompliance(int value)
Desired conformance level for generated PDF document. Read/write PdfCompliance.
Default is PdfCompliance.Pdf17.
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
getPassword()
public final String getPassword()
Setting user password to protect the PDF document. Read/write String.
Returns: java.lang.String
setPassword(String value)
public final void setPassword(String value)
Setting user password to protect the PDF document. Read/write String.
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String |
getAccessPermissions()
public final int getAccessPermissions()
Contains a set of flags specifying which access permissions should be granted when the document is opened with user access. See PdfAccessPermissions.
PdfOptions pdfOptions = new PdfOptions(); pdfOptions.setPassword("my_password"); pdfOptions.setAccessPermissions(PdfAccessPermissions.PrintDocument | PdfAccessPermissions.HighQualityPrint); Presentation presentation = new Presentation(); try { presentation.save(pdfFilePath, SaveFormat.Pdf, pdfOptions); } finally { if (presentation != null) presentation.dispose(); }
Returns: int
setAccessPermissions(int value)
public final void setAccessPermissions(int value)
Contains a set of flags specifying which access permissions should be granted when the document is opened with user access. See PdfAccessPermissions.
PdfOptions pdfOptions = new PdfOptions(); pdfOptions.setPassword("my_password"); pdfOptions.setAccessPermissions(PdfAccessPermissions.PrintDocument | PdfAccessPermissions.HighQualityPrint); Presentation presentation = new Presentation(); try { presentation.save(pdfFilePath, SaveFormat.Pdf, pdfOptions); } finally { if (presentation != null) presentation.dispose(); }
Parameters:
Parameter | Type | Description |
---|---|---|
value | int |
getSaveMetafilesAsPng()
public final boolean getSaveMetafilesAsPng()
True to convert all metafiles used in a presentation to the PNG images. Read/write boolean.
Default is true. Pdf document can contain vector graphics and raster images. If SaveMetafilesAsPng is set to true then source Metafile image is converted to Png format and saved to Pdf as a raster image. If SaveMetafilesAsPng is set to false then source Metafile is converted to Pdf vector graphics. Each approach has advantages and disadvantages. For example, if Metafile is converted to PNG, then some quality loss is possible during resulting document scaling. If Metafile is converted to Pdf vector graphics, then performance issues in Pdf viewing tool are possible.
Returns: boolean
setSaveMetafilesAsPng(boolean value)
public final void setSaveMetafilesAsPng(boolean value)
True to convert all metafiles used in a presentation to the PNG images. Read/write boolean.
Default is true. Pdf document can contain vector graphics and raster images. If SaveMetafilesAsPng is set to true then source Metafile image is converted to Png format and saved to Pdf as a raster image. If SaveMetafilesAsPng is set to false then source Metafile is converted to Pdf vector graphics. Each approach has advantages and disadvantages. For example, if Metafile is converted to PNG, then some quality loss is possible during resulting document scaling. If Metafile is converted to Pdf vector graphics, then performance issues in Pdf viewing tool are possible.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
getSufficientResolution()
public final float getSufficientResolution()
Returns or sets a value determining resolution of images inside PDF document. Read/write float.
Value: Effect of this parameter depends on few factors. Algorithm tries to get best output image size according to the property value, source image size and image frame size. Using of similar property values may give the same result. Recommended to use step 16 or 32 to get visible effect.
Property affects on file size, time of export and image quality.
The default value is 96.
Returns: float
setSufficientResolution(float value)
public final void setSufficientResolution(float value)
Returns or sets a value determining resolution of images inside PDF document. Read/write float.
Value: Effect of this parameter depends on few factors. Algorithm tries to get best output image size according to the property value, source image size and image frame size. Using of similar property values may give the same result. Recommended to use step 16 or 32 to get visible effect.
Property affects on file size, time of export and image quality.
The default value is 96.
Parameters:
Parameter | Type | Description |
---|---|---|
value | float |
getDrawSlidesFrame()
public final boolean getDrawSlidesFrame()
True to draw black frame around each slide. Read/write boolean.
Default is false.
Returns: boolean
setDrawSlidesFrame(boolean value)
public final void setDrawSlidesFrame(boolean value)
True to draw black frame around each slide. Read/write boolean.
Default is false.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
getImageTransparentColor()
public final Color getImageTransparentColor()
Gets or sets the image transparent color.
Value: The color of the image transparent.
Returns: java.awt.Color
setImageTransparentColor(Color value)
public final void setImageTransparentColor(Color value)
Gets or sets the image transparent color.
Value: The color of the image transparent.
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.awt.Color |
getApplyImageTransparent()
public final boolean getApplyImageTransparent()
Applies the specified transparent color to an image if true.
Returns: boolean
setApplyImageTransparent(boolean value)
public final void setApplyImageTransparent(boolean value)
Applies the specified transparent color to an image if true.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
getIncludeOleData()
public final boolean getIncludeOleData()
True to convert all OLE data from the presentation to embedded files in the resulting PDF. Read/write boolean .
Example: Presentation pres = new Presentation("pres.pptx"); try { PdfOptions options = new PdfOptions(); options.setIncludeOleData(true); pres.save("pres.pdf", SaveFormat.Pdf, options); } finally { if (pres != null) pres.dispose(); }
Default is false .
Returns: boolean
setIncludeOleData(boolean value)
public final void setIncludeOleData(boolean value)
True to convert all OLE data from the presentation to embedded files in the resulting PDF. Read/write boolean .
Example: Presentation pres = new Presentation("pres.pptx"); try { PdfOptions options = new PdfOptions(); options.setIncludeOleData(true); pres.save("pres.pdf", SaveFormat.Pdf, options); } finally { if (pres != null) pres.dispose(); }
Default is false .
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |