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

Load files from external server in RadPdfViewer

2 Answers 563 Views
PDFViewer
This is a migrated thread and some comments may be shown as answers.
Ronald
Top achievements
Rank 1
Ronald asked on 06 Feb 2013, 02:09 PM
I'm using RadPdfViewer control, and it works correctly if I write my code like this:

var stream = Application.GetResourceStream(new Uri("SampleData/doc.pdf", UriKind.Relative)).Stream;
pdfViewer.DocumentSource = new PdfDocumentSource(stream);

But I want to load files that are hosted on a server (within the same network). I tried this:

Stream stream = File.OpenRead(@"\\192.168.1.100\pdf$\doc.pdf");              
pdfViewer.DocumentSource = new PdfDocumentSource(stream);

As a test, I try a local file

Stream stream = File.OpenRead(@"C:\pdf\doc.pdf");              
pdfViewer.DocumentSource = new PdfDocumentSource(stream);

Is there a way to do it?

PS: All the files have read permissions are published

2 Answers, 1 is accepted

Sort by
0
Accepted
Petya
Telerik team
answered on 08 Feb 2013, 04:18 PM
Hello Ronald,

Thank you for contacting us!

The latter approach you tried will not work due to Silverlight's restricted access to the file system.

As for showing a file from server, this should be possible if you obtain the respective stream. However, obtaining a stream using the File.OpenRead method in Silverlight is possible only in trusted applications. You should also have in mind that the server is required to have permissive cross-domain policy. You can read more on the matter here and here.

I hope this is helpful!
 
Greetings,
Petya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Ephraïm
Top achievements
Rank 1
Iron
answered on 30 Nov 2021, 04:24 PM

You probably need to create a controller endpoint that serves the pdf file like described here https://docs.telerik.com/kendo-ui/knowledge-base/pdfViewer-load-pdf-dynamically-action-database

 

This worked for me in ASP .Net MVC

Tags
PDFViewer
Asked by
Ronald
Top achievements
Rank 1
Answers by
Petya
Telerik team
Ephraïm
Top achievements
Rank 1
Iron
Share this question
or