Edit this page
Available for: UI for ASP.NET AJAX | UI for ASP.NET MVC | UI for WPF | UI for WinForms | UI for Silverlight

Using PdfFormatProvider

PdfFormatProvider makes it easy to import and export a RadFixedDocument from/to PDF format, preserving the entire document structure and formatting.

In order to use the format provider, you need to add references to the following assemblies:

  • Telerik.Windows.Documents.Core.dll
  • Telerik.Windows.Documents.Fixed.dll
  • Telerik.Windows.Zip.dll


To import a PDF document you need to use the Import() method of PdfFormatprovider.

Example 1 shows how to use PdfFormatProvider to import a PDF document from a file.

PDF files can be opened as long as you can obtain a stream with their content that supports Read and Seek operations. If the stream supports only Read, its content should be copied to a MemoryStream, which will enable the Seek operation as well.

Since Q2 2015 the RadPdfProcessing library exposes new API, which needs to use the stream while working with images in a RadFixedDocument. This requires to keep the stream open and not dispose it.

[C#] Example 1: Import PDF file

PdfFormatProvider provider = new PdfFormatProvider();
using (Stream stream = File.OpenRead("sample.pdf"))
    RadFixedDocument document = provider.Import(stream);

    // Do your work with the document inside the using statement.

The result from the import method is a RadFixedDocument, which can be used like any code-generated document.

Import support is limited to the features that are supported by the export so it is possible that you cannot import all of your custom PDF documents.


Example 2 shows how to use the Export() method of PdfFormatProvider to export RadFixedDocument to a file.

[C#] Example 2: Export PDF file

PdfFormatProvider provider = new PdfFormatProvider();
using (Stream output = File.OpenWrite("sample.pdf"))
    RadFixedDocument document = CreateRadFixedDocument();
    provider.Export(document, output);

The resulting document can be opened in any application which supports PDF documents.

See Also