Link to home
Start Free TrialLog in
Avatar of sticar
sticar

asked on

Open .pdf file through the browser

I went through this site, step by step, and all it does it clear the screen and put a small image icon in the top left side of the screen.  The one that shows if there is a missing image.  I have adobe acrobat reader, and opened the file fine.  I didn't see any "Adobe Acrobat" items in the references list to be added... (if that is the issue)?

http://support.microsoft.com/default.aspx?scid=kb;en-us;307603&Product=vbNET

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Response.ContentType = "Application/pdf"
        'Get the physical path to the file.
        Dim FilePath As String = MapPath("readme.pdf")
        'Write the file directly to the HTTP output stream.
        Response.WriteFile(FilePath)
        Response.End()
    End Sub

Any clue?  Thanks!
Avatar of DotNetLover_Baan
DotNetLover_Baan

are you stuck some where ? this code is working fine, it is opening the file...  What is your exact problem ?
-Baan
Avatar of sticar

ASKER

Strange...  all it does for me is put a little square at the top left, but the link stays the same (which it should).

I don't have to include any resources do I?
are you sure the FilePath variable is pointing to the correct path or the physical file is in the folder?
use File.Exists( FilePath ) method to determine whether the file is there.
Avatar of sticar

ASKER

I went through debugger and it has the full correct path.  It acts like it doesn't see it though.  This may not matter, but the icon for "readme.pdf" is a generic one, not the Adobe Acrobat one, but it will open up in Adobe when I right-click and open it.
Avatar of sticar

ASKER

I just upgraded my Adobe Reader to 6.0.2 from 5.0 and it opens just fine now... ugh.....

Thanks anyway!
Avatar of sticar

ASKER

If you know how I can modify it to open in a separate window, I'll give you the points.

Thanks for all your help!
Hi there,
say you are clicking on a link to open that. In the Page_Load event of the newly opened window, you have the working code. Now go to the parent page (where the link is) and use Javascript:window.open('MyNewPage.aspx')..  just like I showed for the Camtasia Files.
Avatar of sticar

ASKER

? I'm working with a combo box actually so when I change the item it immediately opens the link window.

        If strExt = ".pdf" Then
            Response.ContentType = "Application/pdf"
            'Get the physical path to the file.
            Dim FilePath As String = MapPath(dir + filename)
            'Write the file directly to the HTTP output stream.
            Response.WriteFile(FilePath)                                        'can I put javascript in here somehow?
            Response.End()
        End If
ASKER CERTIFIED SOLUTION
Avatar of ihenry
ihenry

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sticar

ASKER

That is PERFECT!!  I used dropdownlist1
Thank you!!!