I'm trying to use RadPdfViewer in my WPF app but it seems unwieldy. I am wondering if I misunderstand it.
With the normal WPF DocumentViewer and FixedDocument, I can lay out a page in XAML just as I want it and then just add that the the FixedDocument. Can I do this with RadPdfViewer?
Every example I see (in the PdfProcessing examples) has the user creating text blocks, tables and annotations in code-behind and then individually adding them to RadFixedPages. That completely defeats the purpose of using WPF in the first place. I don't want to lay out a report in code-behind. I want to lay out out a XAML page and add it to the report.
But since this stuff comes with your UI for WPF, I assume I must be missing something fundamental.
To be explicit, here is what I do right now when the user tries to generate a report.
- I start off with a view model "PageVm"
- The main report is laid out in ReportView.xaml .
- I've already laid out my report pages with ReportPageView.xaml
// Code behind of ReportView.xaml.cs private void GenerateViewerDoc(ReportPageVm page,Vm Size pageSize){ // Create the document, PageView
var doc = new FixedDocument(); var rc = new ReportPageView { DataContext = pageVm }; doc.DocumentPaginator.PageSize = pageSize; var content = new PageContent() { DataContext = pageVm }; var page = new FixedPage { DataContext = pageVm }; page.Children.Add(rc); ((IAddChild)content).AddChild(page); doc.Pages.Add(content); // Put this new document into the Document Viewer (which is declared in XAML) Viewer.Document = doc; }
Is this possible with Telerik's UI? How do I do it?
