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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to stream pdf on browser

Status
Not open for further replies.

berkshirea

Technical User
Mar 22, 2009
97
0
0
GB
hi guys,i have found this asp script that converts to a pdf file. it's ok but this script writes and saves also the .html and .pdf files into a folder in my server. i don't want that. i just want the .pdf files to be read, streamed and opened by the browser. how can i do that? any ideas guys?

thanks a lot.

here's the code:

<%

Function RandomPW(myLength)
Const minLength = 6
Const maxLength = 20

Dim X, Y, strPW

If myLength = 0 Then
Randomize
myLength = Int((maxLength * Rnd) + minLength)
End If

For X = 1 To myLength
Y = Int((3 * Rnd) + 1) '(1) Numeric, (2) Uppercase, (3) Lowercase

Select Case Y
Case 1
Randomize
strPW = strPW & CHR(Int((9 * Rnd) + 48))
Case 2
Randomize
strPW = strPW & CHR(Int((25 * Rnd) + 65))
Case 3
Randomize
strPW = strPW & CHR(Int((25 * Rnd) + 97))
End Select
Next

RandomPW = strPW
End Function

strPSW = RandomPW(10)

Set conn = Server.CreateObject("ADODB.Connection")
set rs = Server.CreateObject("ADODB.Recordset")
Conn.Open "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " & server.mappath("dbx.mdb") & " ; Persist Security Info = False"

CmdeHTMLDOC = chr(34)&"C:\Program Files\htmldoc\htmldoc.exe" &chr(34)& " -t pdf --quiet "& " --webpage -f "

Set FSO = Server.CreateObject("Scripting.FileSystemObject")
name_fileHTML = strPSW &".html"
dir = Server.MapPath(name_fileHTML)

strSql = "SELECT * FROM TABELLA ORDER BY NAME ASC"
Set objRs = Server.CreateObject("ADODB.Recordset")
objRs.Open strSql, Conn, 3, 3

If Not objRs.EOF Then

set inF = FSO.OpenTextFile(dir, 2, true)
inF.write "<html><body>" &_
"<table border=""1"" width=""100%"">" & "<tr>" & "<th>ID</th>" & "<th>IP</th>" & "<th>NAME</th>" & "</tr>"

Do While Not objRs.EOF
inF.write "<tr>" & "<td>"& objRs("ID") &"</td>" & "<td>"& objRs("IP") &"</td>" & "<td>"& objRs("NAME") &"</td>"
objRs.MoveNext
Loop
inF.close
End If

set wshell = Server.CreateObject("wscript.shell")

fic_html = dir
fic_pdf = Server.MapPath(strPSW &".pdf")
fic_pdf2 = strPSW &".pdf"

wpath = CmdeHTMLDOC &chr(34)& fic_pdf &chr(34)&" "& chr(34)& fic_html &chr(34)

wshell.Run wpath, SW_SHOWNORMAL, true

Set wshell = nothing

objRs.Close
Set objRs = Nothing

Conn.Close
Set Conn = Nothing

%>

<script language="javascript">
alert("Registrazione eseguita correttamente: <%=fic_pdf2%>.");
window.location.href="</script
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top