views:

32

answers:

1

Hi,

i'm a beginner web programmer. I've been coding desktop applications primarily. Right now, i have created this web app, in Silverlight, that uses a web service of my own for querying the database. The thing is, one of the app functionalities is the ability to open PDF files. I know that silverlight won't let you do this, but using an IFrame on top of the silverlight application you are able to display a page with de pdf file (using acrobat plug in). So here's the problem, my silverlight app passes the pdf path to the web service and, in return, the web service would create a new Page and pass the new page URI back so that it can be displayed on the IFrame:

Page Code Behing:

public partial class PDFViewer : System.Web.UI.Page
{
    string Filename = string.Empty;

    public Uri Uri
    {
        get { return HttpContext.Current.Request.Url; }
    }

    public PDFViewer(string filename)
    {
        Filename = filename;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        Response.ContentType = "Application/pdf";

        Response.WriteFile(Filename); //Write the file directly to the HTTP content output stream.

        Response.End();
    }
}

WebMethod Code:

    [WebMethod]
    public string GetReport(string filename)
    {
        PDFViewer viewer = new PDFViewer(filename);

        return viewer.Uri.AbsoluteUri;
    }

this only returns the Web service URL. So the main question is: How to create a page instance and obtain that page URL?

The solution to this might be here: http://forums.silverlight.net/forums/p/76977/372282.aspx

"In my Silverlight app i open a new web browser by passing in query string my id and the page process it, query the db, retrieve the selected object and renders with the response methods."

I just don't know how to do it.

Any help is greatly appreciated.

Pedro

A: 

Maybe this will help.

wherever your silverlight object is embedded put an iframe with id="xContainer"

and from your silverlight code just set its scr to the pdf you're trying to display

HtmlPage.Document.GetElementById("xContainer").SetProperty("src", "http://google.com");
camilin87
thanks for your anwser but i think taht won't solve my problem. the pdf file is stored locally in the server but it isn't deployed with the application.since the web service is in the server machine it can access the file in a given directory (let's say c:\\test.pdf). that's why I create a PDFViewer page and pass it the pdf path. now how can I access the page URL so that my silverlight client loads it in the iframe?thanks in advance
Pedro Sá