Click or drag to resize

PdfConverter Class

This class offers the necessary API to create a PDF document from an Excel workbook: xlsx, xlsm, xltx, xltm, xls, xlt, csv, tsv, SpreadsheetML and markdown, read from a file, a stream or an array of bytes.
Inheritance Hierarchy
SystemObject
  ExpertPdf.Anywhere.ExcelToPdfPdfConverter

Namespace: ExpertPdf.Anywhere.ExcelToPdf
Assembly: ExpertPdf.Anywhere (in ExpertPdf.Anywhere.dll) Version: 22.0
Syntax
public class PdfConverter

The PdfConverter type exposes the following members.

Constructors
 NameDescription
Public methodPdfConverter Creates a Excel to PDF converter.
Top
Properties
 NameDescription
Public propertyAccessibilityStandard Gets or sets the accessibility standard the generated document declares. The default value is None.
Public propertyAutoDetectComplexScript Gets or sets whether right-to-left and complex scripts are detected in text that does not say so. The default value is false.
Public propertyConvertBlankPages Gets or sets whether a page with no content in a sheet's printed range is kept. The default value is false.
Public propertyConvertBlankSheets Gets or sets whether a sheet with no content still produces a page. The default value is false.
Public propertyGridLines Gets or sets whether the cell gridlines are drawn. The default is Automatic.
Public propertyLanguage Gets or sets the natural language of the document content (for example "en-US"). Required for accessible (PDF/UA) output.
Public propertyLayout Gets or sets how the content of a sheet is scaled onto its pages. The default is Automatic: the sheet's own print scaling.
Public propertyLicenseKey Gets or sets the license key
Public propertyPageRanges Gets or sets the pages of the converted workbook to keep, for example "1,3-5" or "2-" (1-based). The default is every page.
Public propertyPageSetup Gets or sets the page size and margins the sheets are laid out on. The default is Document: each sheet's own page setup.
Public propertyPassword Gets or sets the password that opens an encrypted workbook.
Public propertyPdfDocumentInfo Gets a reference to an object to set the document information of the generated PDF document: title, author, subject, keywords and creation date.
Public propertyPdfDocumentOptions Gets a reference to an object to control the generated PDF document options. The page size, orientation and margins are used when PageSetup is Options; the margins also make room for the header and footer.
Public propertyPdfFooterOptions Gets a reference to an object to control the generated PDF document footer options
Public propertyPdfHeaderOptions Gets a reference to an object to control the generated PDF document header options
Public propertyPdfSecurityOptions Gets a reference to an object to set the security of the generated PDF document: a password to open it, an owner password, the permissions and the encryption. The document is encrypted only when one of these options is changed from its default.
Public propertyPdfStandardSubset Gets or sets the PDF standard of the generated document. The default is Full.
Public propertyPreserveFormFields Gets or sets whether the sheets' form controls become PDF form fields. The default value is false: they are drawn as they look.
Public propertySheetBookmarks Gets or sets whether the PDF outline gets an entry per sheet. The default value is true.
Public propertySheetHeadersAndFooters Gets or sets whether the sheets' own printed headers and footers are drawn. The default value is true.
Public propertyWorksheets Gets or sets the sheets to convert, by name, comma separated. The default is every visible sheet; a name the workbook does not have is an error.
Top
Methods
 NameDescription
Public methodGetPdfBytesFromExcelBytes(Byte) Gets the PDF document converted from an Excel workbook given as an array of bytes, its format detected from the content (xlsx, xls, SpreadsheetML or csv).
Public methodGetPdfBytesFromExcelBytes(Byte, ExcelFormat) Gets the PDF document converted from an Excel workbook of the given format given as an array of bytes.
Public methodGetPdfBytesFromExcelFile(String) Gets the PDF document converted from an Excel workbook file, its format taken from the file extension.
Public methodGetPdfBytesFromExcelFile(String, ExcelFormat) Gets the PDF document converted from an Excel workbook file of the given format.
Public methodGetPdfBytesFromExcelStream(Stream) Gets the PDF document converted from an Excel workbook in a stream, its format detected from the content (xlsx, xls, SpreadsheetML or csv).
Public methodGetPdfBytesFromExcelStream(Stream, ExcelFormat) Gets the PDF document converted from an Excel workbook of the given format in a stream.
Public methodSavePdfFromExcelFileToFile Saves the PDF document converted from an Excel workbook file to a file.
Public methodSavePdfFromExcelFileToStream(String, Stream) Saves the PDF document converted from an Excel workbook file to a stream.
Public methodSavePdfFromExcelFileToStream(String, ExcelFormat, Stream) Saves the PDF document converted from an Excel workbook file of the given format to a stream.
Public methodSavePdfFromExcelStreamToFile Saves the PDF document converted from an Excel workbook in a stream to a file.
Public methodSavePdfFromExcelStreamToStream(Stream, Stream) Saves the PDF document converted from an Excel workbook in a stream to another stream.
Public methodSavePdfFromExcelStreamToStream(Stream, ExcelFormat, Stream) Saves the PDF document converted from an Excel workbook of the given format in a stream to another stream.
Top
Remarks

The workbook is printed by the Excel engine, sheet by sheet, as Excel prints it: by default (PageSetup = Document) each sheet keeps its own paper, orientation, margins, scaling, print area and page breaks; with Options every sheet is laid out on the page size, orientation and margins of PdfDocumentOptions. Formulas are calculated, charts, pictures and conditional formats are drawn, and hidden sheets are left out.

Each sheet becomes an entry of the PDF outline (SheetBookmarks), links stay live, and the PDF/A, PDF/X and PDF/UA levels, the security options and the document information apply as they do for the other converters.

Example
PdfConverter pdfConverter = new PdfConverter();
pdfConverter.PdfDocumentOptions.ShowFooter = true;
pdfConverter.PdfFooterOptions.ShowPageNumber = true;
pdfConverter.SavePdfFromExcelFileToFile("report.xlsx", "report.pdf");
See Also