How to open PDF file into iframe from server folder

2 posts, 0 answers
  1. Dhamodharan
    Dhamodharan avatar
    300 posts
    Member since:
    Sep 2010

    Posted 23 Nov 2011 Link to this post

    Hi,

    I want to show PDF file Iframe into Radwindow. if file folder should be website means it is working file. like (/PDFfile/13.pdf). but i have folder outside the webiste but same server. it is name like blobdir. so if i show the pdf iframe means i want to get full src.

    i used another method like,

    Dim strFilePath As String = strPath & Report_file_name.Value
                    If File.Exists(strFilePath) Then
                        _FileName = Report_file_name.Value
                        fs = File.Open(strFilePath, FileMode.Open)
                    Else
                        _FileName = Server.MapPath("EmptyFile.txt")
                        fs = File.Open(strFilePath, FileMode.Open, FileAccess.Read)
                    End If
                    Dim bytBytes(fs.Length) As Byte
                    fs.Read(bytBytes, 0, fs.Length)
                    fs.Close()
                    fs.Dispose()
                    Page.Response.BinaryWrite(bytBytes)
                    Page.Response.Flush()
                    Page.Response.End()

    but is downloaded from server. and asking save, cancel.

    i want to display into iframe from server folder,

    i am using the code like
      iframe1.Attributes.Add("src", "//patrick//blob_dir//1033322RISK_ACKNOWLEDGEMENT.PDF")

    how to get full path for this folder,

    Please give me a tips for this one..

    Thanks in Advance,
    Dhamu.
    Have a nice day....
  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4529 posts

    Posted 24 Nov 2011 Link to this post

    Hello Dhamu,

    What your code does is that it sends the file to the response object which will naturally result in the download dialog on the client. If you want to view the pdf you only need to change the iframe src to the file's URL. Then the browser will take over and if it has the needed plugins and is configured to do so - it will open its PDF reader in the iframe.

    Please note that this is not actually related to the RadWindow, but is the general way things work. If you want to show the pdf in the RadWindow simply change its NavigateUrl and again the browser will decide what to do with the file sent to the iframe of the RadWindow.

    Please also note that you need to pass a valid URL that can be opened on the client as this is where the src of the iframe is applied.


    Greetings,
    Marin
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top