I am Lazy Loading a document in a TabViewItem on the RadTabView Control. Here are the steps.
1. My Page opens and I am on my Main Tab.
2. The user has two Bottom Menu Options, one of them is for a view of a Document.
3. The user selects the Document Tab Option, and the I fire an Async operation that Loads a Byte Array that the PDFViewer is bound to. This loads fine. The document successfully loads in the viewer.
4. The user goes back to the Main Tab
5. The user then selects the Document Tab Option again, the Byte Array is already loaded so I do not Load it again in my ViewModel. So, I am not updating the Source Property on the PDFViewer again once it is loaded. I also tried just reloading the document with the same results.
The application just crashes. My guess is the Rendering or Re-Rendering of the Pdf Document between Tab Selections and there is someting
If the document is never loaded, the app does not crash. However, once I load the document in the PDFViewer that exists on a Tab, the Application will crash if the user moves between tabs.
Stack Trace from the Native Crash Reporting from the Application Output Window.
at <unknown> <0xffffffff>
at SkiaSharp.SkiaApi:sk_canvas_draw_path <0x000fe>
at SkiaSharp.SKCanvas:DrawPath <0x001f2>
at Telerik.XamarinForms.SkiaSharp.PdfSkiaPathPainter:Paint <0x00b42>
at Telerik.XamarinForms.SkiaSharp.SkiaPainterBase:Paint <0x0010f>
at Telerik.XamarinForms.Common.Painters.Painter:TryPaint <0x00176>
at Telerik.XamarinForms.Common.Painters.Painter:Paint <0x003a2>
at Telerik.XamarinForms.SkiaSharp.SkiaPainter:Canvas_PaintSurface <0x0038c>
at SkiaSharp.Views.Forms.SKCanvasView:OnPaintSurface <0x000bc>
at SkiaSharp.Views.Forms.SKCanvasView:SkiaSharp.Views.Forms.ISKCanvasViewController.OnPaintSurface <0x00076>
at SkiaSharp.Views.Forms.SKCanvasViewRendererBase`2:OnPaintSurface <0x001d5>
at SkiaSharp.Views.iOS.SKCanvasView:DrawInSurface <0x0015c>
at SkiaSharp.Views.iOS.SKCanvasView:Draw <0x005b3>
at <Module>:runtime_invoke_void__this___CGRect <0x003f9>
at <unknown> <0xffffffff>
at UIKit.UIApplication:UIApplicationMain <0x00211>
at UIKit.UIApplication:Main <0x000b2>
at UIKit.UIApplication:Main <0x00222>
at EMMA.FINSM.iOS.Application:Main <0x00092>
at <Module>:runtime_invoke_void_object <0x00178>
Example of my Binding. Very simple Byte Array Binding, and out of the box example from the QSF Code. I also tried using a Stream and it does the same thing.
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
/>
</
Grid.RowDefinitions
>
<
telerikPdfViewer:RadPdfViewerToolbar
PdfViewer
=
"{Binding Source={x:Reference PDFView}}"
>
<
telerikPdfViewer:NavigateToPreviousPageToolbarItem
/>
<
telerikPdfViewer:NavigateToNextPageToolbarItem
/>
<
telerikPdfViewer:NavigateToPageToolbarItem
/>
<
telerikPdfViewer:FitToWidthToolbarItem
/>
<
telerikPdfViewer:ToggleLayoutModeToolbarItem
/>
</
telerikPdfViewer:RadPdfViewerToolbar
>
<
telerikPdfViewer:RadPdfViewer
x:Name
=
"PDFView"
Grid.Row
=
"1"
Source
=
"{Binding Document}"
/>
</
Grid
>
public
byte
[] Document
{
get
=> _document;
set
{
SetProperty(
ref
_document, value);
}
}
The pdf content is not visualized properly on UWP and iOS when the file is loaded from a stream.
Also if you try to load PDF twice on the same PDF Viewer, an exception is raised.
When RadPdfViewer is used in a master-detail page, I should maintain the previous page index when I traverse between pages.
System.MissingFieldException: Field not found: Telerik.XamarinForms.SkiaSharp.SkiaDocumentView.purePainter Due to: Could not parse field signature 0a00031b due to: Could not resolve type with token 0100014e from typeref (expected class 'Telerik.XamarinForms.SkiaSharp.DocumentView.SkiaDocumentPurePainter' in assembly 'Telerik.XamarinForms.SkiaSharp, Version=2020.3.1106.460, Culture=neutral, PublicKeyToken=null') assembly:Telerik.XamarinForms.SkiaSharp, Version=2020.3.1106.460, Culture=neutral, PublicKeyToken=null type:Telerik.XamarinForms.SkiaSharp.DocumentView.SkiaDocumentPurePainter member:(null)
at Telerik.XamarinForms.PdfViewer.RadPdfViewer.UpdatePresenter () [0x00037] in <bd15b7ab3df742a5908d5d151a9a58d8>:0
at Telerik.XamarinForms.PdfViewer.RadPdfViewer..ctor () [0x00048] in <bd15b7ab3df742a5908d5d151a9a58d8>:0
at OnaMobile.Views.PdfViewPage.InitializeComponent () [0x00012] in C:\Users\chris\Work\ONAMA\onama-mobile-app\OnaMobile\OnaMobile\obj\Debugetstandard2.0\Views\PdfViewPage.xaml.g.cs:22
at OnaMobile.Views.PdfViewPage..ctor () [0x00008] in C:\Users\chris\Work\ONAMA\onama-mobile-app\OnaMobile\OnaMobile\Views\PdfViewPage.xaml.cs:19
at OnaMobile.ViewModels.ResourcesPageViewModel.OpenResourceAsync (OnaMobile.OnlineResources.ResourceLink resource) [0x001ac] in C:\Users\chris\Work\ONAMA\onama-mobile-app\OnaMobile\OnaMobile\ViewModels\ResourcesPageViewModel.cs:186
iOS SDK 14.1, ARM64. Happens regardless of Linker Behavior setting.
The page itself has nothing in its code-behind other than the default constructor calling InitializeComponent(). In the XAML, the RadPdfViewer control is in a two-row, one-column grid, where it is in the second row:
<Grid VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" ColumnSpacing="0" RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="60" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Frame Grid.Row="0"><!-- ... --></Frame>
<pdf:RadPdfViewer Grid.Row="1" HorizontalOptions="Fill" VerticalOptions="FillAndExpand" Source="{Binding Source}" />
</Grid>
The linear gradient brush in not displayed on some elements.
On images the gradient is visualized.
Text in specific pdf files is not visible in the viewer.
The text is not visualized due to the negative value for font size.