Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

Displaying A PDF Document Inside A Silverlight UserControl RSS

17 replies

Last post Feb 03, 2011 11:03 PM by pdftron

(0)
  • Reny1983

    Reny1983

    Member

    14 Points

    9 Posts

    Displaying A PDF Document Inside A Silverlight UserControl

    Apr 28, 2008 06:43 PM | LINK

    Hello Everyone,

              I am working on a project in Silverlight 2.0. I need to display a PDF document in a Silverlight Usercontrol. How can I do that?Please help! Thanks in advance.

    Reny Mathew

    Silverlight 2.0 Beta PDF

  • chandler.chao

    chandler.chao

    Member

    307 Points

    87 Posts

    Re: Displaying A PDF Document Inside A Silverlight UserControl

    Apr 28, 2008 09:14 PM | LINK

    I do believe that you're going to have to float an iframe on top of your SL app to achieve this.  AFAIK there is no way to instantiate another browser plugin in SL.

    Chandler Chao
    iStreamPlanet
  • Reny1983

    Reny1983

    Member

    14 Points

    9 Posts

    Re: Displaying A PDF Document Inside A Silverlight UserControl

    Apr 30, 2008 02:38 PM | LINK

    Thanks Chandler for your response.  How can I make an IFrame float inside a Silverlight User Control. I am totally new to this technology. Can you give me some examples?

    Thanks, Reny.

  • sladapter

    sladapter

    All-Star

    43607 Points

    7907 Posts

    Re: Displaying A PDF Document Inside A Silverlight UserControl

    Apr 30, 2008 02:56 PM | LINK

    Same as you use IFrame in any HTML page. Set style.position = "absolute" and position it over the Silverlight control. It won't be inside a Silverlight control but on top of it.

    You can put a IFrame tag on your TextPage.HTML/ASPX page.

    <IFRAme id="MyIFrame" style="position:absolute; width:someWidth; height:someHeight; visibility:hidden" /> 

     

    From your silverlight code you can access to the IFrame and set property:

                HtmlElement m = HtmlPage.Document.GetElementById("MyIFrame");          
                if (m != null)
                {

                    m.SetAttribute("src", "URL of your pdf")
                    m.SetStyleAttribute("left", x);
                    m.SetStyleAttribute("top", y);
                    m.SetStyleAttribute("visibility", "visible");
                }

     

    Sally Xu
    Software Engineer
    Aprimo, Inc

    Please remember to mark the replies as answers if they answered your question
  • lewisb

    lewisb

    Member

    217 Points

    82 Posts

    Re: Displaying A PDF Document Inside A Silverlight UserControl

    Apr 30, 2008 03:53 PM | LINK

    I do this exact operation with another activeX control. The one thing that took me a bit to figure out was, the control itself has an IsWindowless parameter that had to be set to -1, in this case, to allow the control to float over the silverlight control.

    For displaying a pdf, I actually pop open another window with a content-disposition header to automatically download.  I may try this method for displaying though. 

    Will this method allow the user to print the pdf individually?

  • sladapter

    sladapter

    All-Star

    43607 Points

    7907 Posts

    Re: Displaying A PDF Document Inside A Silverlight UserControl

    Apr 30, 2008 06:54 PM | LINK

     Yes, I forgot to mention you need to set silverlight object windowless parameter to true in order to have HTML element float over the silverlight control.

    <object data="data:application/x-silverlight," type="application/x-silverlight-2-b1" width="100%" height="100%"> 

    <param name="windowless" value="true" /> 

    <param ../> 

    I never tested print function for IFrame. But I have a EarthLive Map been put into a floating DIV. When I click the browser print, it will only print the Map. But the controls inside Silverlight control are not shown .

     


    Sally Xu
    Software Engineer
    Aprimo, Inc

    Please remember to mark the replies as answers if they answered your question
  • lewisb

    lewisb

    Member

    217 Points

    82 Posts

    Re: Displaying A PDF Document Inside A Silverlight UserControl

    Apr 30, 2008 07:26 PM | LINK

    Excellent, I will have to try this out.  Adding it to my ever growing list of improvements for v2 of our website.

    Thanks!

  • sladapter

    sladapter

    All-Star

    43607 Points

    7907 Posts

    Re: Displaying A PDF Document Inside A Silverlight UserControl

    Apr 30, 2008 07:49 PM | LINK

    lewisb

    Excellent, I will have to try this out.  Adding it to my ever growing list of improvements for v2 of our website.

    Thanks!

     

    I should mention I'm not sure the printout is what you want. In my case, the Map is not full screen. So when print, even it's the only thing shown in the printout, but it still not full page. The rest of the area is just blank.

    Sally Xu
    Software Engineer
    Aprimo, Inc

    Please remember to mark the replies as answers if they answered your question
  • Reny1983

    Reny1983

    Member

    14 Points

    9 Posts

    Re: Re: Displaying A PDF Document Inside A Silverlight UserControl

    May 01, 2008 06:28 PM | LINK

    Thanks guys, I got it working :)

  • arif.mahmood@sungard.com

    arif.mahmood...

    Member

    6 Points

    3 Posts

    Re: Re: Displaying A PDF Document Inside A Silverlight UserControl

    Dec 02, 2008 11:13 PM | LINK

    CAn you send me sample codes. arif.mahmood@sungard.com