PdfSaveOptions Class
Represents a class that stores saving options for Portable Document Format (PDF) file.
public sealed class PdfSaveOptions : SaveOptions
Public NotInheritable Class PdfSaveOptions
Inherits SaveOptions
- Inheritance:
- System.ObjectPdfSaveOptions
Remarks
For more information about a level of support for PDF format, see supported file formats.
For more information about PDF encryption, see Permissions remarks.
Constructors
PdfSaveOptions()
Initializes a new instance of the PdfSaveOptions class.
Properties
BookmarksCreateOptions
Gets or sets a value indicating whether to create PDF bookmarks (outlines).
Default value: UsingHeadings (for backward compatibility).
public PdfBookmarksCreateOptions BookmarksCreateOptions { get; set; }
Public Property BookmarksCreateOptions As PdfBookmarksCreateOptions
Property Value
A value indicating whether to create PDF bookmarks (outlines).
ConformanceLevel
Gets or sets the level of conformance for PDF document.
public PdfConformanceLevel ConformanceLevel { get; set; }
Public Property ConformanceLevel As PdfConformanceLevel
Property Value
The level of conformance for PDF document.
ContentType
Gets the content-type for PDF file format: application/pdf.
public override string ContentType { get; }
Public Overrides ReadOnly Property ContentType As String
Property Value
- System.String
The content-type for PDF file format.
Overrides
DigitalSignature
Gets or sets the digital signature options.
public PdfDigitalSignatureSaveOptions DigitalSignature { get; set; }
Public Property DigitalSignature As PdfDigitalSignatureSaveOptions
Property Value
The digital signature options.
DocumentOpenPassword
Specifies the password required for opening the encrypted PDF document.
public string DocumentOpenPassword { get; set; }
Public Property DocumentOpenPassword As String
Property Value
- System.String
The password required for opening the encrypted PDF document.
Remarks
Generated PDF document will be encrypted if any of the following conditions are satisfied:
- Permissions is different than All.
- PermissionsPassword is not null or System.String.Empty.
- DocumentOpenPassword is not null or System.String.Empty.
Both PermissionsPassword and DocumentOpenPassword are optional but with the following consequences:
- If Permissions is different than All and PermissionsPassword is not specified, component will generate random PermissionsPassword.
- Using PermissionsPassword, also known as owner password, without DocumentOpenPassword is not secure. It relies on PDF viewer software to respect specified restrictions, but it may choose not to do so.
- Using DocumentOpenPassword, also known as user password, is potentially very secure. It or PermissionsPassword is required for decrypting and viewing the document.
- When DocumentOpenPassword is specified, PDF viewer application will prompt for password to decrypt and present the document. If entered password is DocumentOpenPassword, document will be decrypted and presented with specified Permissions enforced. Otherwise, if entered password is PermissionsPassword, document will be decrypted and presented without any restrictions.
DocumentOpenPassword and PermissionsPassword cannot be equal, otherwise exception is thrown.
For more information, see PDF Encryption example.
ImageDpi
Gets or sets the saved images DPI.
Property Value
- System.Int32
The saved images DPI.
Remarks
This property controls the image quality for all images in the file. Larger value results in better-quality images but increases the file size. Setting this property to 0 will disable image optimization. Standard DPI values are:
- 330 - Good quality for HD displays
- 220 - Good quality for most printers and displays
- 150 - Good quality for web pages and projectors
- 96 - Good quality for smaller file sizes
Using this property you basically specify the DPI of the display device on which the file will be viewed and for which the images in the file should be optimized without losing any perceived quality because images go through the same resampling (reduction of pixel count) as they would in the viewer application if viewing the file using the default (100%) zoom factor on that display device.
For example, if an image whose pixel size is 600px × 400px
is shown on page where it occupies a slot whose physical size is 150pt × 100pt
, then if the display device DPI is 144px/inch
, the viewer application will show the image in a display slot whose pixel size is 300px × 200px
if the default (100%) zoom factor is used (Rationale: there are always 72 points per inch and for the DPI of 144, there are 144 pixels per inch, so 150[pt] = 150[pt] × 144[px/inch] / 72[pt/inch] = 300[px]
).
So the viewer application has to fit an image into a smaller display slot and it will do so by resampling the image from 600px × 400px
to 300px × 200px
.
Reducing the total number of pixels 4 times (from 240000 to 60000) would also reduce the image file size, so GemBox component can do this instead of the viewer application, thus achieving the overall smaller file size without any perceived loss of quality since the same image resampling would have been done by the viewer application anyway if the default (100%) zoom factor is used.
Instructing the GemBox component to perform image resampling (by setting the ImageDpi property to the DPI of the display device on which the file is going to be viewed) has two effects:
- Major benefit: output file size will be smaller if there are images whose pixel size is greater than their display size because those images are resampled to a smaller number of pixels without any perceived loss of quality since the same resampling would have been done by the viewer application anyway.
- Minor benefit: viewer application will be able to present the image faster because it needs to decode a fewer number of pixels and because the display slot size will be exactly equal to the image pixel size so it doesn't have to perform any resampling if the default (100%) zoom factor is used.
MetafileScaleFactor
Gets or sets the scaling factor for rendering metafile (WMF and EMF) images. Greater scaling factor improves quality but also increases file size. Default value is 1.
public double MetafileScaleFactor { get; set; }
Public Property MetafileScaleFactor As Double
Property Value
- System.Double
The metafile scale factor for rendering metafile (WMF and EMF) images.
Remarks
Windows Metafile Format (WMF) and Enhanced Metafile Format (EMF) are vector image formats which contain a series of graphics drawing commands usually executed in Windows GDI layer.
Metafile drawing commands could also be executed in PDF (or XPS) file which is also vector format, but for that Metafile drawing commands would have to be converted to PDF drawing commands.
GemBox.Document currently doesn't perform this conversion of drawing commands, instead it uses Windows GDI to execute Metafile drawing commands into bitmap which is then encoded to PNG format and embedded into PDF file.
MetafileScaleFactor specifies the size of the bitmap surface, based from the original Metafile surface size, into which Metafile should be drawn / rasterized.
PDF viewer will still scale the bitmap to the original Metafile size, but if the page is zoomed or viewed on a larger surface, quality of the image will be better since it contains more pixels / dots which will become visible while PDF viewer scales down the image.
MetafileScaleFactor increases the quality of the Metafile image in PDF file, but it also increases the size of the PDF file because greater MetafileScaleFactor means greater bitmap surface and more space to store bitmap pixel / color data. PNG encoding / compression helps in reducing the space requirement and for complex Metafiles (with a lot of drawing instructions), MetafileScaleFactor of 5 or even greater, might not incur any space overhead relative to the original (complex) Metafile.
Default value for MetafileScaleFactor is 1.
Permissions
Gets or sets the operations that are allowed to a user on an encrypted PDF document.
public PdfPermissions Permissions { get; set; }
Public Property Permissions As PdfPermissions
Property Value
The operations that are allowed to a user on an encrypted PDF document.
Remarks
Generated PDF document will be encrypted if any of the following conditions are satisfied:
- Permissions is different than All.
- PermissionsPassword is not null or System.String.Empty.
- DocumentOpenPassword is not null or System.String.Empty.
Both PermissionsPassword and DocumentOpenPassword are optional but with the following consequences:
- If Permissions is different than All and PermissionsPassword is not specified, component will generate random PermissionsPassword.
- Using PermissionsPassword, also known as owner password, without DocumentOpenPassword is not secure. It relies on PDF viewer software to respect specified restrictions, but it may choose not to do so.
- Using DocumentOpenPassword, also known as user password, is potentially very secure. It or PermissionsPassword is required for decrypting and viewing the document.
- When DocumentOpenPassword is specified, PDF viewer application will prompt for password to decrypt and present the document. If entered password is DocumentOpenPassword, document will be decrypted and presented with specified Permissions enforced. Otherwise, if entered password is PermissionsPassword, document will be decrypted and presented without any restrictions.
DocumentOpenPassword and PermissionsPassword cannot be equal, otherwise exception is thrown.
For more information, see PDF Encryption example.
PermissionsPassword
Specifies the password for opening the encrypted PDF document without any access restrictions.
public string PermissionsPassword { get; set; }
Public Property PermissionsPassword As String
Property Value
- System.String
The password for opening the encrypted PDF document without any access restrictions.
Remarks
Generated PDF document will be encrypted if any of the following conditions are satisfied:
- Permissions is different than All.
- PermissionsPassword is not null or System.String.Empty.
- DocumentOpenPassword is not null or System.String.Empty.
Both PermissionsPassword and DocumentOpenPassword are optional but with the following consequences:
- If Permissions is different than All and PermissionsPassword is not specified, component will generate random PermissionsPassword.
- Using PermissionsPassword, also known as owner password, without DocumentOpenPassword is not secure. It relies on PDF viewer software to respect specified restrictions, but it may choose not to do so.
- Using DocumentOpenPassword, also known as user password, is potentially very secure. It or PermissionsPassword is required for decrypting and viewing the document.
- When DocumentOpenPassword is specified, PDF viewer application will prompt for password to decrypt and present the document. If entered password is DocumentOpenPassword, document will be decrypted and presented with specified Permissions enforced. Otherwise, if entered password is PermissionsPassword, document will be decrypted and presented without any restrictions.
DocumentOpenPassword and PermissionsPassword cannot be equal, otherwise exception is thrown.
For more information, see PDF Encryption example.
RasterizeVectorPictures
Gets or sets a value indicating whether to rasterize vector pictures.
public bool RasterizeVectorPictures { get; set; }
Public Property RasterizeVectorPictures As Boolean
Property Value
- System.Boolean
The value indicating whether to rasterize vector pictures.
Version
Gets or sets the version of the PDF specification to which the PDF document conforms specified in the PDF file's header (see 7.5.2, "File Header").
Note that the PDF file's header version might be coerced to a value higher than the one specified in Version if the PDF file uses features that are not supported by the version specified in Version.
If the value is null then PDF file's header version will be automatically set to a specific value depending on the features used in the PDF file.
Default value: null.
Property Value
- System.Nullable<PdfVersion>
The version of the PDF specification to which the PDF document conforms specified in the PDF file's header.
Events
ProgressChanged
Occurs when saving progress of a document has changed.
public event EventHandler<OperationProgressChangedEventArgs> ProgressChanged
Public Event ProgressChanged As EventHandler(Of OperationProgressChangedEventArgs)
Event Type
- System.EventHandler<OperationProgressChangedEventArgs>
Inherited Properties
DocxDefault | Gets the default saving options for Microsoft Word file format. Word file will be saved in Docx format. (Inherited from SaveOptions) |
HtmlDefault | Gets the default saving options for HyperText Markup Language (HTML) format. (Inherited from SaveOptions) |
ImageDefault | Gets the default saving options for image file format. Image will be saved in Bmp format. (Inherited from SaveOptions) |
OdtDefault | Gets the default saving options for Open Document file format. (Inherited from SaveOptions) |
PageCount | Gets or sets the number of pages which should be saved. (Inherited from SaveOptions) |
PageNumber | Gets or sets the zero-based page number of the document's page which should be saved. (Inherited from SaveOptions) |
PdfDefault | Gets the default saving options for Portable Document Format (PDF). (Inherited from SaveOptions) |
RtfDefault | Gets the default saving options for Rich Text (RTF) format. (Inherited from SaveOptions) |
TxtDefault | Gets the default saving options for Plain Text (TXT) format. (Inherited from SaveOptions) |
XmlDefault | Gets the default saving options for XML file format. (Inherited from SaveOptions) |
XpsDefault | Gets the default saving options for XML Paper Specification (XPS) format. (Inherited from SaveOptions) |