Hi,
I am using telerik PDF viewer in my wpf application, i am following MVVM pattern to bind pdf to pdf viewer control. I have a PDF content as byte array which on load will be read into memory stream and then loaded to PDF document (code given below).
pdf is loading perfectly and i am able to get the selected page, selected content and i am also able to save the start & end of the previous selection and apply the same back on the pdf.
currently i am trying to reload a new pdf content and apply the saved selection indexes (start and end) and extract the text between the indexes.
my application runs in background (no ui controls) and the pdf content (byte[]) is fetched from an API and this new content must be loaded to pdfdocument (Telerik.Windows.Documents.Fixed.PdfDocumentSource) and the saved indexes must be re applied and the content between the selected region must be extracted.
problem is when i load the byte[] then there is no error but the documentsource.Document is null . how do i get this working ? can i apply the selection indexes to Fixed.PdfDocumentSource and read selection content.
below is the code that i am using.
Note: i am passing command descriptors to viewmodel constructor.
<telerik:RadPdfViewer x:Name="pdfViewer" RenderOptions.BitmapScalingMode="HighQuality" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="1" DocumentSource="{Binding PDFDocument,Mode=TwoWay}" Mode="TextSelection">
</telerik:RadPdfViewer>
private Telerik.Windows.Documents.Fixed.PdfDocumentSource _PDFDocument;
/// <summary>
/// Pdf Document Source
/// </summary>
public Telerik.Windows.Documents.Fixed.PdfDocumentSource PDFDocument {
get {
return _PDFDocument;
}
set {
_PDFDocument = value;
OnPropertyChanged("PDFDocument");
}
}
/// <summary>
///
/// </summary>
private void LoadPDFDocument(byte[] pdfdata) {
if (pdfdata != null) {
MemoryStream DocumentStream = new MemoryStream(pdfdata);
Telerik.Windows.Documents.Fixed.FormatProviders.FormatProviderSettings settings = new Telerik.Windows.Documents.Fixed.FormatProviders.FormatProviderSettings(Telerik.Windows.Documents.Fixed.FormatProviders.ReadingMode.OnDemand);
PDFDocument = new Telerik.Windows.Documents.Fixed.PdfDocumentSource(DocumentStream, settings);
}
}