Load files from external server in RadPdfViewer

2 posts, 1 answers
  1. Ronald
    Ronald avatar
    1 posts
    Member since:
    May 2009

    Posted 06 Feb 2013 Link to this post

    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(@"\\\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. Answer
    Petya avatar
    983 posts

    Posted 08 Feb 2013 Link to this post

    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!
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top