Edit this page

Exception Handling

RadPdfViewer provides an API for handling exceptions caused by documents which cannot be loaded correctly because of unsupported features of the control. More information about the unsupported features in RadPdfViewer is available here.

How to Handle Exceptions

RadPdfViewer exposes an DataError event.

Using the DateError event

public PdfDataExceptionCode()
{
    InitializeComponent();
    radPdfViewer1.DataError += radPdfViewer1_DataError;
}
void radPdfViewer1_DataError(object sender, PdfExceptionEventArgs args)
{
    NotSupportedFilterException filterException = args.Exception as NotSupportedFilterException;
    if (filterException != null)
    {
        // The document contains a filter which is not supported.
    }
}

Public Sub New()
    InitializeComponent()
    AddHandler radPdfViewer1.DataError, AddressOf radPdfViewer1_DataError
End Sub
Private Sub radPdfViewer1_DataError(ByVal sender As Object, ByVal args As PdfExceptionEventArgs)
    Dim filterException As NotSupportedFilterException = TryCast(args.Exception, NotSupportedFilterException)
    If filterException IsNot Nothing Then
        ' The document contains a filter which is not supported.
    End If
End Sub

The PdfExceptionEventArgs argument exposed the following property:

  • Exception: This property represents the actual exception thrown by RadPdfViewer. All exceptions for features which are not supported by RadPdfViewer inherit from the Telerik.Windows.Pdf.Documents.Exceptions.NotSupportedFeatureException class:

  • NotSupportedFilterException: Represents an exception for a filter which is not supported. This exception has a FilterName property which specifies the name of the filter.

  • NotSupportedEncryptionException: Represents an exception for an encryption which is not supported. This exception has e EncryptionCode property which specifies the code of the encryption.

  • NotSupportedFontException: Represents an exception for a font which is not supported. This exception has a FontType property which specifies the type of the font.

  • NotSupportedShadingTypeException: Represents an exception for a shading type which is not supported. This exception has e ShadingType property which specifies the type of the shading.

  • NotSupportedStreamTypeException: Represents an exception for a stream type which is not supported. A stream is not supported if it does not support read or seek. This exception has a SupportSeek and SupportRead properties which specify whether the stream supports them.

  • NotSupportedPredefinedCMapException: Represents an exception for a predefined CMap which is not supported by RadPdfViewer. This exception has a CMapName which specifies the name of the predefined CMap.

  • NotSupportedScanDecoderException: This exception is thrown if the document contains a scan decoder which is not supported by RadPdfViewer.

  • NotSupportedXObjectTypeException: This exception is thrown if the document contains a XObject type which is not supported by RadPdfViewer.

See Also