Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read and Display a pdf file from the server location as binary data

Status
Not open for further replies.

Cheryl3D

Programmer
Mar 26, 2002
116
US
Hi:

I have a web-based application that uses ASP with SQL Server 2000 in the background. I have a field called ‘weblink’ within a database table that list the names of pdf files (that includes the .pdf extension). These documents are stored on a network share drive.

Using ASP code, I have hard-coded a portion of the path (beginning with \\servername\ISSA…), that is everything up to the name of the pdf file. See the sample code below:

do while not rs.eof
counter=counter+1
weblink=trim(rs("doc_weblink") & "")
if weblink<>"" then
weblink="<a href='\\servername\ISSA\ISSA Scanned\" & weblink & "' target='_blank'>" & weblink & "</a>"
end if

I would like to read and display binary data in ASP. In other words, I would like to read and display the pdf file from the server location as binary data.

I have some code that I started to use on an ASP page:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<% option explicit %>

<%
Response.Clear
Response.ContentType="application/pdf"
Response.AddHeader "content-type", "application/pdf"
Response.Buffer = True

Dim oHttp
Set oHttp = Server.CreateObject("Scripting.FileSystemObject")


oHttp.Open "GET", "\\servername\ISSA\ISSA Scanned\FX7054-01052-103 Final 5 Aug 02.pdf", False

oHttp.Send

Response.BinaryWrite oHttp.ResponseBody

Set oHttp = Nothing
%>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="application/pdf; charset=iso-8859-1">
</head>

<body>

</body>
</html>
------------------------------------ End of Code ----------------------------------------------

I’m just trying to get this to send binary data via ASP. When I run this code I get an Expected Statement error at the <% Option Explicit %> line of code, in the browser.


Can anyone provide some very good code that helps me to read and display binary data, in this case a pdf file. Any one have some good code for writing a custom business object or component that adds the functionality (to read and display binary data in an IE browser). My primary objective is to send an existing Adode Acrobat (.pdf) document to the browser. I just want to get these (.pdf) files to the client. These documents are kept in a location other than the hierarchy underneath the web root.

My stream is:
\\servername\ISSA\ISSA Scanned\FX7054-01052-103 Final 5 Aug 02.pdf

But my problem is that I don’t know how to incorporate it in the ASP code.

Also, am I using the Response.BinaryWrite method to push the data back to the client correctly?

Please bear with me, as I’m new to this concept of reading and displaying binary data.

Any help on this matter would be greatly appreciated. I’m a little lost on this one.

Thanks

Cheryl

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top