Class PdfSaveOptions
Namespace: Aspose.Cells
Assembly: Aspose.Cells.dll (25.2.0)
Represents the options for saving pdf file.
public class PdfSaveOptions : PaginatedSaveOptions
Inheritance
object ← SaveOptions ← PaginatedSaveOptions ← PdfSaveOptions
Inherited Members
PaginatedSaveOptions.DefaultFont, PaginatedSaveOptions.CheckWorkbookDefaultFont, PaginatedSaveOptions.CheckFontCompatibility, PaginatedSaveOptions.IsFontSubstitutionCharGranularity, PaginatedSaveOptions.OnePagePerSheet, PaginatedSaveOptions.AllColumnsInOnePagePerSheet, PaginatedSaveOptions.IgnoreError, PaginatedSaveOptions.OutputBlankPageWhenNothingToPrint, PaginatedSaveOptions.PageIndex, PaginatedSaveOptions.PageCount, PaginatedSaveOptions.PrintingPageType, PaginatedSaveOptions.GridlineType, PaginatedSaveOptions.TextCrossType, PaginatedSaveOptions.DefaultEditLanguage, PaginatedSaveOptions.SheetSet, PaginatedSaveOptions.DrawObjectEventHandler, PaginatedSaveOptions.PageSavingCallback, PaginatedSaveOptions.EmfRenderSetting, SaveOptions.m_SaveFormat, SaveOptions.SaveFormat, SaveOptions.ClearData, SaveOptions.CachedFileFolder, SaveOptions.ValidateMergedAreas, SaveOptions.MergeAreas, SaveOptions.CreateDirectory, SaveOptions.SortNames, SaveOptions.SortExternalNames, SaveOptions.RefreshChartCache, SaveOptions.WarningCallback, SaveOptions.CheckExcelRestriction, SaveOptions.UpdateSmartArt, SaveOptions.EncryptDocumentProperties, object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Constructors
PdfSaveOptions()
Creates the options for saving pdf file.
public PdfSaveOptions()
Properties
Bookmark
Gets and sets the Aspose.Cells.Rendering.PdfBookmarkEntry?text=PdfBookmarkEntry object.
public PdfBookmarkEntry Bookmark { get; set; }
Property Value
CalculateFormula
Indicates whether to calculate formulas before saving pdf file.
public bool CalculateFormula { get; set; }
Property Value
Remarks
The default value is false.
Compliance
Gets or sets the PDF standards compliance level for output documents.
public PdfCompliance Compliance { get; set; }
Property Value
Remarks
Default is Pdf17.
CreatedTime
Gets and sets the time of generating the pdf document.
public DateTime CreatedTime { get; set; }
Property Value
Remarks
if it is not be set, it will be the time of generating the pdf.
CustomPropertiesExport
Gets or sets a value determining the way Aspose.Cells.Properties.CustomDocumentPropertyCollection are exported to PDF file. Default value is None.
public PdfCustomPropertiesExport CustomPropertiesExport { get; set; }
Property Value
DisplayDocTitle
Indicates whether the window’s title bar should display the document title.
public bool DisplayDocTitle { get; set; }
Property Value
Remarks
If false, the title bar should instead display the name of the PDF file. Default value is false.
EmbedAttachments
Indicates whether to embed attachment for Ole objects in Excel.
public bool EmbedAttachments { get; set; }
Property Value
Remarks
Default value is false. The value must be false when PDF/A compliance is set or pdf encryption is enabled.
EmbedStandardWindowsFonts
True to embed true type fonts. Affects only ASCII characters 32-127. Fonts for character codes greater than 127 are always embedded. Fonts are always embedded for PDF/A-1a, PDF/A-1b standard. Default is true.
public bool EmbedStandardWindowsFonts { get; set; }
Property Value
ExportDocumentStructure
Indicates whether to export document structure.
public bool ExportDocumentStructure { get; set; }
Property Value
FontEncoding
Gets or sets embedded font encoding in pdf.
public PdfFontEncoding FontEncoding { get; set; }
Property Value
Remarks
Default value is Aspose.Cells.Rendering.PdfFontEncoding.Identity
OptimizationType
Gets and sets pdf optimization type.
public PdfOptimizationType OptimizationType { get; set; }
Property Value
Remarks
Default value is Aspose.Cells.Rendering.PdfOptimizationType.Standard
PdfCompression
Indicate the compression algorithm
public PdfCompressionCore PdfCompression { get; set; }
Property Value
Producer
Gets and sets producer of generated pdf document.
public string Producer { get; set; }
Property Value
Remarks
If the value is null, or a valid LICENSE is not set, string Aspose.Cells vVERSION will be used.
SecurityOptions
Set this options, when security is need in xls2pdf result.
public PdfSecurityOptions SecurityOptions { get; set; }
Property Value
Examples
The following code sets hight resolution print permisson for the output pdf.
csharp
Workbook wb = new Workbook();
wb.Worksheets[0].Cells["A1"].Value = "Aspose";
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
PdfSecurityOptions pdfSecurityOptions = new PdfSecurityOptions();
//set owner password
pdfSecurityOptions.OwnerPassword = "YourOwnerPassword";
//set user password
pdfSecurityOptions.UserPassword = "YourUserPassword";
//set print permisson
pdfSecurityOptions.PrintPermission = true;
//set high resolution for print
pdfSecurityOptions.FullQualityPrintPermission = true;
pdfSaveOptions.SecurityOptions = pdfSecurityOptions;
wb.Save("output.pdf", pdfSaveOptions);
Watermark
Gets or sets watermark to output.
public RenderingWatermark Watermark { get; set; }
Property Value
Examples
The following code sets watermark in the output pdf.
csharp
//prepare a workbook with 3 pages.
Workbook wb = new Workbook();
wb.Worksheets[0].Cells["A1"].PutValue("Page1");
int index = wb.Worksheets.Add();
wb.Worksheets[index].Cells["A1"].PutValue("Page2");
index = wb.Worksheets.Add();
wb.Worksheets[index].Cells["A1"].PutValue("Page3");
wb.Worksheets[index].PageSetup.PaperSize = PaperSizeType.PaperA3;
//create a font for watermark, and specify bold, italic, color
RenderingFont font = new RenderingFont("Calibri", 68);
font.Italic = true;
font.Bold = true;
font.Color = Color.Blue;
//create a watermark from text and the specified font
RenderingWatermark watermark = new RenderingWatermark("Watermark", font);
//specify horizontal and vertical alignment
watermark.HAlignment = TextAlignmentType.Center;
watermark.VAlignment = TextAlignmentType.Center;
//specify rotation
watermark.Rotation = 30;
//specify opacity
watermark.Opacity = 0.6f;
//specify the scale to page(e.g. 100, 50) in percent.
watermark.ScaleToPagePercent = 50;
//spcify watermark for rendering to pdf.
PdfSaveOptions options = new PdfSaveOptions();
options.Watermark = watermark;
wb.Save("output_watermark.pdf", options);
Methods
SetImageResample(int, int)
Sets desired PPI(pixels per inch) of resample images and jpeg quality.
All images will be converted to JPEG with the specified quality setting,
and images that are greater than the specified PPI (pixels per inch) will be resampled.
public void SetImageResample(int desiredPPI, int jpegQuality)
Parameters
desiredPPI
int
Desired pixels per inch. 220 high quality. 150 screen quality. 96 email quality.
jpegQuality
int
0 - 100% JPEG quality.
Examples
The following code sets desired PPI as 96 and jpeg quality as 80 for images in the output pdf.
csharp
//load the source file with images.
Workbook wb = new Workbook("Book1.xlsx");
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
//set desired PPI as 96 and jpeg quality as 80.
pdfSaveOptions.SetImageResample(96, 80);
wb.Save("output.pdf", pdfSaveOptions);