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

pdf from file

2 Answers 43 Views
PdfViewer
This is a migrated thread and some comments may be shown as answers.
Abderrazak
Top achievements
Rank 1
Abderrazak asked on 20 Aug 2019, 10:19 AM

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ß

 

 

2 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 21 Aug 2019, 11:31 AM
Hello Abderrazak,

I checked the snippet and actually File.OpenRead method returns a Stream object  - the stream should be then passed to the PdfViewer Source (instead of filepath).

Please try it like this and let me know the result.

If this does not help, you can try handling the SourceException event in order to receive more information on the reason for not loading the file.

I look forward to your reply.

Regards,
Yana
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Abderrazak
Top achievements
Rank 1
answered on 21 Aug 2019, 01:55 PM

Hey Yana,

all good, i remove this line File.OpenRead(filepath)  and works fine :) 

Thanks

Tags
PdfViewer
Asked by
Abderrazak
Top achievements
Rank 1
Answers by
Yana
Telerik team
Abderrazak
Top achievements
Rank 1
Share this question
or