Using PdfFormatProvider
RadWordsProcessing provides a PdfFormatProvider class that allows you to export a RadFlowDocument to PDF.
To use PdfFormatProvider, add references to the following packages:
- Telerik.Windows.Documents.Core
- Telerik.Windows.Documents.Flow
- Telerik.Windows.Documents.Flow.FormatProviders.Pdf
- Telerik.Windows.Documents.Fixed
Starting with Q2 2025, the Zip Library is no longer used as an internal dependency in the rest of the Document Processing Libraries—PdfProcessing, WordsProcessing, SpreadProcessing, SpreadStreamProcessing. It is replaced by System.IO.Compression. The Telerik Zip Library continues to ship as a standalone library so you can still use it separately.
Export
To export a document to PDF, use the Export() method of PdfFormatProvider.
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. That is why you need to 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
ImageQualitydifferent than High, set theJpegImageConverterproperty inside theFixedExtensibilityManager. For more information, check the FixedExtensibilityManager in the PdfProcessing Cross-Platform Support article.
The code snippet in Example 1 shows how to create a PdfFormatProvider instance and use it to export a RadFlowDocument to a file.
The
PdfFormatProviderclass of RadWordsProcessing is located in theTelerik.Windows.Documents.Flow.FormatProviders.Pdfnamespace.
Example 1: Export to PDF File
Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider provider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
using (Stream output = File.OpenWrite("sample.pdf"))
{
RadFlowDocument document = CreateRadFlowDocument();
provider.Export(document, output, TimeSpan.FromSeconds(10));
}
The result from the method is a document that you can open in any application that supports PDF documents.
Example 2 demonstrates how to export the contents of a RadFlowDocument to a RadFixedDocument.
Example 2: Export to RadFixedDocument
RadFlowDocument document = CreateRadFlowDocument();
Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider provider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
RadFixedDocument fixedDocument = provider.ExportToFixedDocument(document, TimeSpan.FromSeconds(10));
RadFixedDocumentis the base class of the RadPdfProcessing library. Additional information on the library and its functionality is available in the RadPdfProcessing Overview.