Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Open PDF in new window

Reply
Thread Tools

Open PDF in new window

 
 
Paul Eaton
Guest
Posts: n/a
 
      07-08-2003
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
%>
 
Reply With Quote
 
 
 
 
Stuart Palmer
Guest
Posts: n/a
 
      07-08-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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
> %>



 
Reply With Quote
 
 
 
 
Tom B
Guest
Posts: n/a
 
      07-08-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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
> %>



 
Reply With Quote
 
Paul Eaton
Guest
Posts: n/a
 
      07-09-2003
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" <(E-Mail Removed)> wrote in message news:<#(E-Mail Removed)>...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) om...
> > 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
> > %>

 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      07-09-2003
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)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Postscript to PDF with pdf-tools, pdf-writer, or other Sean Nakasone Ruby 1 04-14-2008 09:13 PM
PDF::Writer, create pdf and insert in other pdf file. Ricardo Pog Ruby 1 03-26-2008 08:24 PM
Window.Open get new tab instead of new window in FireFox Fredzidd@gmail.com Javascript 1 02-29-2008 03:06 AM
window.open() doesn't open new Window in Opera PC HUA Javascript 2 05-19-2004 02:29 AM
Need to open a new browser window, not a new window Gordon ASP General 3 04-16-2004 10:46 PM



Advertisments