Category / Section
How to display the PDF file in Silverlight platform?
1 min read
Silverlight does not allow you to pass the stream of data to the aspx page, however a workaround is created to display the PDF by using the html Iframe. The following code example and sample link demonstrate the same.
C#
System.Windows.Browser.HtmlElement myFrame = System.Windows.Browser.HtmlPage.Document.GetElementById("_sl_historyFrame"); if (myFrame != null) { myFrame.SetStyleAttribute("width", "1024"); myFrame.SetStyleAttribute("height", "768"); Uri uri = new Uri(HtmlPage.Document.DocumentUri, "ClientBin/sample.pdf"); string path = uri.AbsoluteUri.ToString(); myFrame.SetAttribute("src", path); myFrame.SetStyleAttribute("left", "0"); myFrame.SetStyleAttribute("top", "50"); myFrame.SetStyleAttribute("visibility", "visible"); }