I'm trying to write a pdf file to the browser and when the client print the pdf the filename sent to the printer is the name of the file. But now i'm getting the name of the asp page sent to the browser "loadfile.asp"
Because I can't put a title in my page when i'm using Response.ContentType = "application/pdf"
, I've added a page that do a server.Transfer
.
But everytime the code pass trought the Response.ContentType = "application/pdf"
the title get blanked.
So here's my code : First Page :
<html>
<head>
<title>
<%= Request.QueryString("File") & ".PDF" %>
</title>
</head>
<body>
<%
Server.Transfer "loadfileAfter.asp"
%>
</body>
</html>
Here's the Second Page (loadfileAfter.asp) :
Response.ContentType = "application/pdf"
Response.AddHeader "content-disposition", "Filename=" & Request.QueryString("File") & ".PDF"
Const adTypeBinary = 1
strFilePath = "D:\" & Request.QueryString("File") & ".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
I tought that this line would help :
Response.AddHeader "content-disposition", "Filename=" & Request.QueryString("File") & ".PDF"
But it did not change a thing.
Thanks for your help