Articles in this section
Category / Section

How workaround is created to display PDF file in Silverlight?

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");
            }

Sample link:



Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied