Using PdfFormatProvider
PdfFormatProvider is part of SpreadProcessing and allows export to PDF format.
Using PdfFormatProvider
PdfFormatProvider makes it easy to export a Workbook to PDF format. Each Worksheet exported to PDF is divided into pages according to its WorksheetPageSetup. For more information about paging a Worksheet, see the Worksheet Page Setup article.
For more examples and application scenarios of importing and exporting a Workbook to various formats using a FormatProvider, check out the Import/Load and Export/Save RadSpreadProcessing Workbook knowledge base article.
Prerequisites
To use PdfFormatProvider, add references to the following packages:
-
.NET Framework, .NET 8, .NET 9 and .NET 10 (or later) for Windows
- Telerik.Windows.Documents.Spreadsheet
- Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf
-
.NET Standard 2.0 (.NET 8, .NET 9 and .NET 10)
- Telerik.Documents.Spreadsheet
- Telerik.Documents.Spreadsheet.FormatProviders.Pdf
Export
The .NET Standard specification does not define APIs for getting specific fonts.
PdfFormatProviderneeds access to the font data so that it can read it and add it to the PDF file. To allow the library to create and use fonts, you must provide an implementation of theFontsProviderBaseabstract class and set this implementation to theFontsProviderproperty ofFixedExtensibilityManager. For detailed information, check the Cross-Platform Support article.
.NET Standard: To export images different than Jpeg and Jpeg2000 or ImageQuality different than High, set the
JpegImageConverterproperty inside theFixedExtensibilityManager. For more information, check the PdfProcessing Cross-Platform Support article.
Example 1 shows how to use PdfFormatProvider to export a Workbook to a file.
Example 1: PdfFormatProvider Export Example
Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.PdfFormatProvider pdfFormatProvider = new Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.PdfFormatProvider();
using (Stream output = File.OpenWrite("Sample.pdf"))
{
Workbook workbook = CreateSampleWorkbook(); // The CreateSampleWorkbook() method generates a sample spreadsheet document. Use your Workbook object here.
pdfFormatProvider.Export(workbook, output, TimeSpan.FromSeconds(10));
}
The result from the export method is a document that you can open in any application that supports PDF documents.
Example 2: Export to RadFixedDocument
Workbook workbook = CreateSampleWorkbook();
Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.PdfFormatProvider provider = new Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.PdfFormatProvider();
RadFixedDocument fixedDocument = provider.ExportToFixedDocument(workbook, TimeSpan.FromSeconds(10));
RadFixedDocumentis the base class of theRadPdfProcessinglibrary. For more information about the library and its features, see the RadPdfProcessing Overview.