Setting Source from some other site to PDFViewer dynamically

2 posts, 0 answers
  1. Srinivas Dharanipragada
    Srinivas Dharanipragada avatar
    4 posts
    Member since:
    Feb 2010

    Posted 19 Jul 2012 Link to this post


    I am trying to set the source of the pdfviewer dynamically as shown in the code below.

      this.viewer.DocumentSource = new PdfDocumentSource(new System.Uri("http://localhost/AssessmentDemo/Documents/ModuleDocument/a2b93ea5-796f-44c9-a84a-9cfe0f48e6b3-SBICard_monthlystmt_Jun12.pdf", UriKind.Absolute));

    It's not working. Please suggest me a solution
  2. Kammen
    Kammen avatar
    312 posts

    Posted 20 Jul 2012 Link to this post

    Hi Srinivas,

    As you can see in this article, there are two different constructors that allow you to create PdfDocumentSource. When you want to use the one with the Uri, you must be sure that you can obtain a Stream that supports both Read and Seek operations from the Uri.

    If that is not the case, you can use the constructor that takes a Stream parameter. For example, you can pass a stream to your file and wrap it in a MemoryStream if it does not support Read and Seek operations.

    Note that when you use the second approach, you may want to close the stream after the document is loaded. In order to do this, you can attach to the Loaded event of the PdfDocumentSource where you can safely close the stream.

    I hope this helps.

    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top