PDF Open new window?

Posted on 2005-04-09
Last Modified: 2010-04-07
I finally got my application to work where on a blank page a pdf will open (the pdf is being brought out of a database as a ole object).  The only problem I have having now is the fact that it opens in a acrobat window and leaves the ie window blank, so you have two windows open.  How can I make it open within IE??

Here is my code.

If rd.Read() Then

                    Dim filename As String
                    Dim filesize As Integer
                    Dim contenttype As String

                    filename = rd.GetString(0)
                    filesize = rd.GetInt32(1)
                    contenttype = rd.GetString(2)

                    Dim filedata(filesize) As Byte

                    rd.GetBytes(3, 0, filedata, 0, filesize)

                    If (forceDownload) Then
                        Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename)
                        Response.AppendHeader("Content-Disposition", "inline; filename=" + filename)
                    End If
                    Response.ContentType = contenttype
                    Response.OutputStream.Write(filedata, 0, filedata.Length)
                End If

Question by:macros14
    LVL 26

    Expert Comment

    pdf cannot be opened with IE, unless u get some activex control which wil can add within the form and which inturn will open the pdf file within it ...
    how the pdf file should behave is configured in ur PC,
    open explorer ..
    in the menu tool->option->file types tab
    seelct the pdf type .. click on advanced button .. u will see that "Open in the same window" is disabled .. if this was enabled, u could check it and then ur pdf will open in the same window as IE ..
    LVL 20

    Accepted Solution

    Sample code on how to open a pdf file to a new browser window via javascript and code behind.

    Open .pdf file through the browser
    LVL 26

    Expert Comment

    As I understand, even that would open the pdf file in its own exe and not within the browser window ..
    LVL 20

    Expert Comment

    I promise you, if you try the code you will see a pdf file inside your browser:o) It is so called browser's plug-in capability

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now