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

Setting Source from some other site to PDFViewer dynamically

1 Answer 71 Views
PDFViewer
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Srinivas Dharanipragada
Top achievements
Rank 1
Srinivas Dharanipragada asked on 19 Jul 2012, 10:55 AM
Hello,

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

1 Answer, 1 is accepted

Sort by
0
Kammen
Telerik team
answered on 20 Jul 2012, 11:12 AM
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.


Greetings,
Kammen
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
PDFViewer
Asked by
Srinivas Dharanipragada
Top achievements
Rank 1
Answers by
Kammen
Telerik team
Share this question
or