Hi,
Having used the demo app, I am now trying to add the RadPdfViewer control only to my solution. I am following these instructions (https://docs.telerik.com/devtools/xamarin/controls/pdfviewer/pdfviewer-getting-started).
I initially tried the NuGet package but ran into an "error MSB6006: "java.exe" exited with code 2." situation. I tried increasing the java max heap size passed my current value of 1G, but this did not get resolved.
I then tried the manual DLL reference method, however upon building the solution, I run into the following error :-
error: package com.telerik.android.common does not exist
Therefore, from the list of DLLs for the Android project, it seems like Telerik.Xamarin.Android.Common.dll is missing.
I then reference Telerik.Xamarin.Android.Common.dll and although I am now able to build the solution, I run into the following exception when trying to navigate to a page that contains the RadPdfViewer control :-
NativeResourceProvider.ToPlatformPixels (System.Double dip)
System.TypeInitializationException: Exception of type 'System.Exception' was thrown
Am I missing some additional references?
As a side note, is there a way to fix the "error MSB6006: "java.exe" exited with code 2." when using the NuGet package, as this would ideally be my preference.
Hi at All,
i try to open a pdf file from device when using this code :
var doc = DependencyService.Get<IFiles>().GetPath(path);
var filepath = Path.Combine(doc, pdfName);
if (File.Exists(filepath))
{
File.OpenRead(filepath);
pdfViewer.Source = filepath;
}
i get this error : an error occured while loading the document.
may be i do somthing wrong !?
Gruß
Hi,
Just two questions:
- Is it possible to click on WEB link inside PDF ?
- Whan you zoom in, quality decreases (blur effect), is it normal ? It is not vectorial ?
If not, is it planned to add it ?
Thank you
Hi,
I have a Xamarin Forms project, with Telerik PDF Viewer.
I simply added a PDF Viewer on a page, for testing it:
- opening a PDF with an URL
- Opening a PDF with Stream as Embedded Resource
Results:
On IOS, it's OK for Both
On UWP it's OK for Stream loading, but I have an error on URL "An error occurred while loading the document"
On Android, OK for both URL and Stream loading, but when I rotate the device, the PDF Viewer is completely blocked.(tested on Nexus 5X emulator and Samsung S9 real device)
As there currently isn't a way to determine when a page changes when scrolling, I hook into the PropertyChanged event of the RadPdfViewer and check the VisiblePagesStartIndex property, however when scrolling to the last page of the PDF the VisiblePagesStartIndex does not match, for example, I have a 10 page PDF document and when I scroll all the way to the bottom, the last VisiblePagesStartIndex property change is 8, when it should be 9. If I then invoke the NavigateToNextPageCommand then the VisiblePagesStartIndex property changes to the expected value of 9, although I am already at the bottom of the document.
In effect I need to know when I reach the end of the PDF so that I can update my own UI buttons to reflect the current position in the document, for example, disabling the down button when I can no longer navigate to a next page. I can achieve this when using the NavigateToNextPageCommand and NavigateToPreviousPageCommand method of document navigation but not when scrolling.
I have tried a work around where if the VisiblePagesStartIndex is 8 then invoke the NavigateToNextPageCommand but this doesn't work when scrolling back up the document.
I would like to invoke the NavigateToNextPageCommand, NavigateToPreviousPageCommand and NavigateToPageCommand commands from code behind however I am having a bit of trouble.
I have successfully invoked the NavigateToNextPageCommand using the following code :-
if (PdfViewerControl2.NavigateToNextPageCommand.CanExecute(null))
{
PdfViewerControl2.NavigateToNextPageCommand.Execute(null);
CurrentPageNumber++;
SetCanExecutes(BindingContext as SmartDocViewModel);
}
However, using a similar approach for the NavigateToPreviousPageCommand, the CanExecute method against the command returns false.
Also I am trying to invoke the NavigateToPageCommand in such a way that it acts as a beginning/end command, so I pass either 1 or the VisiblePagesCount value (last page) to the NavigateToPageCommand command however it does not change the page.
The provided sample uses the commands directly via buttons in the XAML however due to my use case I need to invoke the commands in code behind.
Would you be able to help me?
PdfViewer : FitToWidth on StartUp?
Is there a setting to set the viewer to display fit to width when the pdf file opens?
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
ContentPage
xmlns
=
"http://xamarin.com/schemas/2014/forms"
xmlns:telerikPdf
=
"clr-namespace:Telerik.XamarinForms.PdfViewer;assembly=Telerik.XamarinForms.PdfViewer"
xmlns:telerikCommon
=
"clr-namespace:Telerik.XamarinForms.Common;assembly=Telerik.XamarinForms.Common"
x:Class
=
"TelerikXamarinApp1.Portable.Page1"
>
<
ContentPage.Content
>
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
/>
</
Grid.RowDefinitions
>
<
telerikPdf:RadPdfViewerToolbar
PdfViewer
=
"{Binding Source={x:Reference pdfViewer}}"
>
<
telerikPdf:ZoomInToolbarItem
/>
<
telerikPdf:ZoomOutToolbarItem
/>
<
telerikPdf:NavigateToNextPageToolbarItem
/>
<
telerikPdf:NavigateToPreviousPageToolbarItem
/>
<
telerikPdf:NavigateToPageToolbarItem
/>
<
telerikPdf:FitToWidthToolbarItem
/>
<!--<telerikPdf:ToggleLayoutModeToolbarItem/>-->
</
telerikPdf:RadPdfViewerToolbar
>
<
telerikPdf:RadPdfViewer
x:Name
=
"pdfViewer"
Grid.Row
=
"1"
FitToWidthCommand
=
""
/>
</
Grid
>
<!--<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
/>
</
Grid.RowDefinitions
>
<
telerikCommon:RadUniformGrid
>
<
Button
Text
=
"Zoom In"
Command
=
"{Binding Source={x:Reference pdfViewer}, Path=ZoomInCommand}"
/>
<
Button
Text
=
"Zoom Out"
Command
=
"{Binding Source={x:Reference pdfViewer}, Path=ZoomOutCommand}"
/>
<
Button
Text
=
"Fit To Width"
Command
=
"{Binding Source={x:Reference pdfViewer}, Path=FitToWidthCommand}"
/>
<
Button
Text
=
"Previous Page"
Command
=
"{Binding Source={x:Reference pdfViewer}, Path=NavigateToPreviousPageCommand}"
/>
<
Button
Text
=
"Next Page"
Command
=
"{Binding Source={x:Reference pdfViewer}, Path=NavigateToNextPageCommand}"
/>
</
telerikCommon:RadUniformGrid
>
<
telerikPdf:RadPdfViewer
x:Name
=
"pdfViewer"
Grid.Row
=
"1"
MinZoomLevel
=
"0.3"
MaxZoomLevel
=
"4"
/>
</
Grid
>-->
<!--<
StackLayout
>
<
Label
Text
=
"Invoice Viewer"
VerticalOptions
=
"CenterAndExpand"
HorizontalOptions
=
"CenterAndExpand"
/>
<
telerikPdf:RadPdfViewerToolbar
PdfViewer
=
"{Binding Source={x:Reference pdfViewer}}"
>
<
telerikPdf:NavigateToPreviousPageToolbarItem
/>
<
telerikPdf:NavigateToPageToolbarItem
/>
<
telerikPdf:NavigateToNextPageToolbarItem
/>
<
telerikPdf:ZoomInToolbarItem
/>
<
telerikPdf:ZoomOutToolbarItem
/>
<
telerikPdf:FitToWidthToolbarItem
/>
</
telerikPdf:RadPdfViewerToolbar
>
<
telerikPdf:RadPdfViewer
x:Name
=
"pdfViewer"
Scale
=
"50"
FitToWidthCommand
=
"True"
/>
</
StackLayout
>-->
</
ContentPage.Content
>
</
ContentPage
>
Regards,
Graham