RadFixedDocument

RadFixedDocument is the class representing a PDF document inside RadPdfViewer.

Since R3 2020 RadPdfViewer uses PdfProcessing and its RadFixedDocument as a model.

Creation

You can create a PDF document with the API of PdfProcessing and directly assing it to RadPdfViewer.

Example 1: Create a PDF document and show it

RadFixedDocument document = new RadFixedDocument(); 
using (RadFixedDocumentEditor editor = new RadFixedDocumentEditor(document)) 
{ 
    editor.InsertRun("Hello PDF!"); 
} 
 
this.pdfViewer.Document = document; 

For an existing PDF document, an instance of RadFixedDocument can be created using PdfFormatProvider and assigned to RadPdfViewer in the following way:

Example 2: Import a PDF document

Stream stream = Application.GetResourceStream(new Uri("PdfViewerDemo;component/SampleData/test.pdf", UriKind.Relative)).Stream; 
 
Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider pdfFormatProvider = new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider(); 
pdfFormatProvider.ImportSettings = Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Import.PdfImportSettings.ReadOnDemand; 
 
RadFixedDocument document = pdfFormatProvider.Import(stream); 
this.pdfViewer.Document = document; 

The PdfFormatProvider of RadPdfViewer must not be confused with that of RadRichTextBox. Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider is the provider that RadPdfViewer uses to import files. It is located in the Telerik.Windows.Documents.Fixed assembly.For reference, the Telerik.Windows.Documents.FormatProviders.Pdf.PdfFormatProvider of RadRichTextBox is included in the Telerik.Windows.Documents.FormatProviders.Pdf assembly, in a namespace with the same name. The latter can be used only to export RadDocument to PDF.

As you can see, the Import() method of PdfFormatProvider accepts two parameters – stream with the contents of the PDF file and format provider settings specifying the loading mode.

Members

For details about the model used by PdfViewer and the members of RadFixedDocument, check the documentation of PdfProcessing.

See Also

In this article
Not finding the help you need? Improve this article