This is a migrated thread and some comments may be shown as answers.

Pdfviewer show "an error occurred while loading the document" on android in release

2 Answers 473 Views
PdfViewer
This is a migrated thread and some comments may be shown as answers.
n/a
Top achievements
Rank 1
n/a asked on 07 Apr 2021, 07:26 AM

Hi,

I have developed an Xamarin application that in Modal show a pdf in a PdfViewer.

PdfViewerPage pdfViewer = new PdfViewerPage(item.IdAllegato, item.Path, item.FlagScaricabile);
Navigation.PushModalAsync(pdfViewer);

 

When the Modal is open, I assign a url to the PdfViewer source.

pdfViewer.Source = new Uri(uri);

 

Everything is fine when I run the android app on debug mode, but when I run in release mode the PdfViewer show this message: "an error occurred while loading the document"

2 Answers, 1 is accepted

Sort by
0
Accepted
Didi
Telerik team
answered on 07 Apr 2021, 11:51 AM

Hello Giuseppe, 

I am not sure what could be the issue as in debug mode the pdf is displayed in the viewer.

As you are getting an error -> In order to get the exception message you can use the SourceException event. For more details please check the PdfViewer Source Exception Handling topic -> https://docs.telerik.com/devtools/xamarin/controls/pdfviewer/pdfviewer-sourceexception 

private void PdfViewerSourceException(object sender, SourceExceptionEventArgs e)
{
    var error = e.Exception.Message;
}

Then based on the exception we can continue investigating the case. In addition, you can send us the pdf document. Open a support ticket and attach the document to it, because in the forum only image attachments are allowed. 

Regards,
Didi
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
n/a
Top achievements
Rank 1
answered on 07 Apr 2021, 12:59 PM

Hi,

thank you for the support. I have used the SourceException event and I solved the problem. The pdf url had http instead of https.

Best regards,

Davide

Tags
PdfViewer
Asked by
n/a
Top achievements
Rank 1
Answers by
Didi
Telerik team
n/a
Top achievements
Rank 1
Share this question
or