GemBox.Spreadsheet
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    PdfSaveOptions Class

    Namespace:
    GemBox.Spreadsheet
    Assembly:
    GemBox.Spreadsheet.dll

    Represents options for saving to Portable Document Format (PDF) file.

    • C#
    • VB.NET
    public sealed class PdfSaveOptions : SaveOptions
    Public NotInheritable Class PdfSaveOptions
        Inherits SaveOptions
    Inheritance:
    System.Object
    SaveOptions
    PdfSaveOptions

    Constructors

    PdfSaveOptions()

    Initializes a new instance of the PdfSaveOptions class.

    • C#
    • VB.NET
    public PdfSaveOptions()
    Public Sub New

    Properties

    ConformanceLevel

    Gets or sets the level of conformance for PDF document.

    • C#
    • VB.NET
    public PdfConformanceLevel ConformanceLevel { get; set; }
    Public Property ConformanceLevel As PdfConformanceLevel
    Property Value
    PdfConformanceLevel

    The level of conformance for PDF document.

    ContentType

    Gets the content-type for PDF file format: application/pdf.

    • C#
    • VB.NET
    public override string ContentType { get; }
    Public Overrides ReadOnly Property ContentType As String
    Property Value
    System.String

    The content-type for PDF file format.

    Overrides
    SaveOptions.ContentType

    DigitalSignature

    Gets or sets the digital signature options.

    • C#
    • VB.NET
    public PdfDigitalSignatureSaveOptions DigitalSignature { get; set; }
    Public Property DigitalSignature As PdfDigitalSignatureSaveOptions
    Property Value
    PdfDigitalSignatureSaveOptions

    The digital signature options.

    DocumentOpenPassword

    Specifies the password required for opening the encrypted PDF document.

    • C#
    • VB.NET
    public string DocumentOpenPassword { get; set; }
    Public Property DocumentOpenPassword As String
    Property Value
    System.String
    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.

    ExtendedOptions

    Gets the extended save options that are not natively supported by spreadsheet formats.

    • C#
    • VB.NET
    public ExtendedSaveOptions ExtendedOptions { get; }
    Public ReadOnly Property ExtendedOptions As ExtendedSaveOptions
    Property Value
    ExtendedSaveOptions

    Extended save options that are not natively supported by spreadsheet formats.

    ImageDpi

    Gets or sets the saved images DPI.

    • C#
    • VB.NET
    public int ImageDpi { get; set; }
    Public Property ImageDpi As Integer
    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.

    Limitations

    Gets limitations for saving to PDF file format.

    • C#
    • VB.NET
    public override FileFormatLimitations Limitations { get; }
    Public Overrides ReadOnly Property Limitations As FileFormatLimitations
    Property Value
    FileFormatLimitations
    Overrides
    SaveOptions.Limitations
    Remarks

    These are the limits:

    • MaxRows: System.Int32.MaxValue
    • MaxColumns: System.Int32.MaxValue
    • MaxColors: System.Int32.MaxValue
    • MaxCellStyles: System.Int32.MaxValue

    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.

    • C#
    • VB.NET
    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.

    • C#
    • VB.NET
    public PdfPermissions Permissions { get; set; }
    Public Property Permissions As PdfPermissions
    Property Value
    PdfPermissions
    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.

    PermissionsPassword

    Specifies the password for opening the encrypted PDF document without any access restrictions.

    • C#
    • VB.NET
    public string PermissionsPassword { get; set; }
    Public Property PermissionsPassword As String
    Property Value
    System.String
    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.

    RasterizeVectorPictures

    Gets or sets a value indicating whether to rasterize vector pictures.

    • C#
    • VB.NET
    public bool RasterizeVectorPictures { get; set; }
    Public Property RasterizeVectorPictures As Boolean
    Property Value
    System.Boolean

    The value indicating whether to rasterize vector pictures.

    SelectionType

    Gets or sets a value indicating whether to save the whole ExcelFile or just ActiveWorksheet.

    • C#
    • VB.NET
    public SelectionType SelectionType { get; set; }
    Public Property SelectionType As SelectionType
    Property Value
    SelectionType

    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.

    • C#
    • VB.NET
    public PdfVersion? Version { get; set; }
    Public Property Version As PdfVersion?
    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 file has changed.

    • C#
    • VB.NET
    public event EventHandler<OperationProgressChangedEventArgs> ProgressChanged
    Public Event ProgressChanged As EventHandler(Of OperationProgressChangedEventArgs)
    Event Type
    System.EventHandler<OperationProgressChangedEventArgs>

    Inherited Properties

    CsvDefault

    Gets the default options for saving to Character Separated Values file format.

    (Inherited from SaveOptions)

    HtmlDefault

    Gets the default options for saving to HyperText Markup Language File format.

    (Inherited from SaveOptions)

    ImageDefault

    Gets the default options for saving to image formats.

    (Inherited from SaveOptions)

    OdsDefault

    Gets the default options for saving to OpenDocument Spreadsheet file format.

    (Inherited from SaveOptions)

    PdfDefault

    Gets the default options for saving to Portable Document Format file.

    (Inherited from SaveOptions)

    TxtDefault

    Gets the default options for saving to Tab delimited file format.

    (Inherited from SaveOptions)

    XlsDefault

    Gets the default options for saving to, XLS file format (Microsoft Excel Spreadsheet format; Excel 2003 and prior versions) .

    (Inherited from SaveOptions)

    XlsbDefault

    Gets the default options for saving to XLSB file format (Microsoft Excel Binary File Format).

    (Inherited from SaveOptions)

    XlsxDefault

    Gets the default options for saving to XLSX file format (Microsoft Excel Open XML Spreadsheet; Excel 2007 and later).

    (Inherited from SaveOptions)

    XpsDefault

    Gets the default options for saving to XML Paper Specification file format.

    (Inherited from SaveOptions)

    Examples

    Convert Excel files to PDF in C# and VB.NET
    PDF digital signature examples
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.