Open PDF in new window

Discussion in 'ASP General' started by Paul Eaton, Jul 8, 2003.

  1. Paul Eaton

    Paul Eaton Guest

    Hi

    I am developing my first asp appication (vbscript). I am storing
    cheques scans (in pdf format) in the file system along with the db on
    the server.

    The following code is working without problem except that:-

    I want to display the scan/pdf in a new window and keep the current
    window at the current position within the application.

    Thanks in advance if you can spare the time to show me the best way to
    do this.

    Paul

    (peaton at franklin templeton d.o.t com (with no _))

    <%@ Language="VBScript" %>
    <% Option Explicit %>
    <% response.buffer = true %>
    <%
    'On Error Resume Next
    Const adTypeBinary = 1
    Dim strFilePath

    Dim RecID
    Dim ImagePath
    Dim strSecLevel
    Dim strSecSubLevel
    Dim objStream

    ImagePath="e:\IncomingChequesScans\"
    strSecLevel=session("seclevel")
    strSecSubLevel=session("secsublevel")
    RecID=Request.QueryString("id")

    'Set the content type to the specific type that you are sending.
    Response.ContentType = "seclevel/pdf"

    strFilePath = ImagePath & RecID & ".pdf" 'This is the path to the file
    on disk.

    Set objStream = Server.CreateObject("ADODB.Stream")
    objStream.Open
    objStream.Type = adTypeBinary
    objStream.LoadFromFile strFilePath

    Response.BinaryWrite objStream.Read

    objStream.Close
    Set objStream = Nothing
    %>
     
    Paul Eaton, Jul 8, 2003
    #1
    1. Advertising

  2. I guess you are clicking on something to pop this up? in that case, on this
    link add the target="_Blank" line and javascript window.open call.

    As ASP is server side, it can not open a new browser window on your users
    machine.

    Stuart Palmer

    "Paul Eaton" <> wrote in message
    news:...
    > Hi
    >
    > I am developing my first asp appication (vbscript). I am storing
    > cheques scans (in pdf format) in the file system along with the db on
    > the server.
    >
    > The following code is working without problem except that:-
    >
    > I want to display the scan/pdf in a new window and keep the current
    > window at the current position within the application.
    >
    > Thanks in advance if you can spare the time to show me the best way to
    > do this.
    >
    > Paul
    >
    > (peaton at franklin templeton d.o.t com (with no _))
    >
    > <%@ Language="VBScript" %>
    > <% Option Explicit %>
    > <% response.buffer = true %>
    > <%
    > 'On Error Resume Next
    > Const adTypeBinary = 1
    > Dim strFilePath
    >
    > Dim RecID
    > Dim ImagePath
    > Dim strSecLevel
    > Dim strSecSubLevel
    > Dim objStream
    >
    > ImagePath="e:\IncomingChequesScans\"
    > strSecLevel=session("seclevel")
    > strSecSubLevel=session("secsublevel")
    > RecID=Request.QueryString("id")
    >
    > 'Set the content type to the specific type that you are sending.
    > Response.ContentType = "seclevel/pdf"
    >
    > strFilePath = ImagePath & RecID & ".pdf" 'This is the path to the file
    > on disk.
    >
    > Set objStream = Server.CreateObject("ADODB.Stream")
    > objStream.Open
    > objStream.Type = adTypeBinary
    > objStream.LoadFromFile strFilePath
    >
    > Response.BinaryWrite objStream.Read
    >
    > objStream.Close
    > Set objStream = Nothing
    > %>
     
    Stuart Palmer, Jul 8, 2003
    #2
    1. Advertising

  3. Paul Eaton

    Tom B Guest

    Add a target to your link on the first page

    <a href="GetCheque.asp?RecID=2112" target="_new">View Cheque 2112</a>

    OR, use the javascript window.open to specify formatting options

    <script language=Javascript>
    function OpenCheque(chequeNum)
    {
    window.open('GetCheque.asp?RecID=' + chequeNum,'newwin','height=200,
    width=500, top=200, left=200');
    }
    </script>

    <a href="Javascript: OpenCheque('2112');">View Cheque 2112</a>


    TomB

    "Paul Eaton" <> wrote in message
    news:...
    > Hi
    >
    > I am developing my first asp appication (vbscript). I am storing
    > cheques scans (in pdf format) in the file system along with the db on
    > the server.
    >
    > The following code is working without problem except that:-
    >
    > I want to display the scan/pdf in a new window and keep the current
    > window at the current position within the application.
    >
    > Thanks in advance if you can spare the time to show me the best way to
    > do this.
    >
    > Paul
    >
    > (peaton at franklin templeton d.o.t com (with no _))
    >
    > <%@ Language="VBScript" %>
    > <% Option Explicit %>
    > <% response.buffer = true %>
    > <%
    > 'On Error Resume Next
    > Const adTypeBinary = 1
    > Dim strFilePath
    >
    > Dim RecID
    > Dim ImagePath
    > Dim strSecLevel
    > Dim strSecSubLevel
    > Dim objStream
    >
    > ImagePath="e:\IncomingChequesScans\"
    > strSecLevel=session("seclevel")
    > strSecSubLevel=session("secsublevel")
    > RecID=Request.QueryString("id")
    >
    > 'Set the content type to the specific type that you are sending.
    > Response.ContentType = "seclevel/pdf"
    >
    > strFilePath = ImagePath & RecID & ".pdf" 'This is the path to the file
    > on disk.
    >
    > Set objStream = Server.CreateObject("ADODB.Stream")
    > objStream.Open
    > objStream.Type = adTypeBinary
    > objStream.LoadFromFile strFilePath
    >
    > Response.BinaryWrite objStream.Read
    >
    > objStream.Close
    > Set objStream = Nothing
    > %>
     
    Tom B, Jul 8, 2003
    #3
  4. Paul Eaton

    Paul Eaton Guest

    Thankyou for the responses

    I have used the window.open version in a JScript function
    'ViewImage':-

    <input type=button value="View Image" name=Image1
    onClick="ViewImage('<% =RecID %>')">


    As I don't think I can put a 'target'in:-

    <input type=button value="View Image" name=Image1
    onClick="location.href='../GCS/GCSImageView.asp?id=<% =RecID
    %>&mode=view'">

    Regards
    Paul




    "Tom B" <> wrote in message news:<#>...
    > Add a target to your link on the first page
    >
    > <a href="GetCheque.asp?RecID=2112" target="_new">View Cheque 2112</a>
    >
    > OR, use the javascript window.open to specify formatting options
    >
    > <script language=Javascript>
    > function OpenCheque(chequeNum)
    > {
    > window.open('GetCheque.asp?RecID=' + chequeNum,'newwin','height=200,
    > width=500, top=200, left=200');
    > }
    > </script>
    >
    > <a href="Javascript: OpenCheque('2112');">View Cheque 2112</a>
    >
    >
    > TomB
    >
    > "Paul Eaton" <> wrote in message
    > news:...
    > > Hi
    > >
    > > I am developing my first asp appication (vbscript). I am storing
    > > cheques scans (in pdf format) in the file system along with the db on
    > > the server.
    > >
    > > The following code is working without problem except that:-
    > >
    > > I want to display the scan/pdf in a new window and keep the current
    > > window at the current position within the application.
    > >
    > > Thanks in advance if you can spare the time to show me the best way to
    > > do this.
    > >
    > > Paul
    > >
    > > (peaton at franklin templeton d.o.t com (with no _))
    > >
    > > <%@ Language="VBScript" %>
    > > <% Option Explicit %>
    > > <% response.buffer = true %>
    > > <%
    > > 'On Error Resume Next
    > > Const adTypeBinary = 1
    > > Dim strFilePath
    > >
    > > Dim RecID
    > > Dim ImagePath
    > > Dim strSecLevel
    > > Dim strSecSubLevel
    > > Dim objStream
    > >
    > > ImagePath="e:\IncomingChequesScans\"
    > > strSecLevel=session("seclevel")
    > > strSecSubLevel=session("secsublevel")
    > > RecID=Request.QueryString("id")
    > >
    > > 'Set the content type to the specific type that you are sending.
    > > Response.ContentType = "seclevel/pdf"
    > >
    > > strFilePath = ImagePath & RecID & ".pdf" 'This is the path to the file
    > > on disk.
    > >
    > > Set objStream = Server.CreateObject("ADODB.Stream")
    > > objStream.Open
    > > objStream.Type = adTypeBinary
    > > objStream.LoadFromFile strFilePath
    > >
    > > Response.BinaryWrite objStream.Read
    > >
    > > objStream.Close
    > > Set objStream = Nothing
    > > %>
     
    Paul Eaton, Jul 9, 2003
    #4
  5. Paul Eaton

    Evertjan. Guest

    Paul Eaton wrote on 09 jul 2003 in microsoft.public.inetserver.asp.general:
    > <input type=button value="View Image" name=Image1
    > onClick="location.href='../GCS/GCSImageView.asp?id=<% =RecID
    > %>&mode=view'">



    <input type=button value="View Image"
    onClick=
    "window.open('../GCS/GCxxx.asp?id=<%=RecID%>&mode=view')">


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Jul 9, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kim

    Open .pdf in new window

    Kim, Nov 18, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    2,155
  2. Daniel Geisenhoff
    Replies:
    1
    Views:
    6,219
    Steven Cheng[MSFT]
    Apr 16, 2004
  3. Gordon
    Replies:
    3
    Views:
    330
    Steven Burn
    Apr 16, 2004
  4. PC HUA
    Replies:
    2
    Views:
    446
    PC HUA
    May 19, 2004
  5. Replies:
    1
    Views:
    259
Loading...

Share This Page