Solved

set default filename when saving binary-written-to-browser pdf

Posted on 2004-10-06
2
1,139 Views
Last Modified: 2008-01-09
i am displaying PDF files in a web browser using asp

i am trying to set the default filename (that appears in the file name box) when the "save a copy of the file" button is clicked, but it seems that i can't

following is my code:

Response.Buffer = True
Response.Clear
Response.ContentType = "application/pdf"
Response.AddHeader "Content-Disposition", "inline; filename=x.pdf"
Response.BinaryWrite sBinaryFile
Response.Flush
Response.End

any ideas?

thanks,

f
0
Comment
Question by:papaflo
  • 2
2 Comments
 
LVL 10

Accepted Solution

by:
dij8 earned 50 total points
ID: 12242941
You have no control over these kind of boxes that appear on the clients browser.  This is a security issue.  It is also that the save as dialog box is not actually part of the browser but part of the native operating system.  The box will always come up with the name of the file being saved, in this case "x.pdf".

A way around this is to use the FileSystemObject and copy the PDF document to a folder naming it whatever you want and then rendering the page using the copied file.  This will still open the save as dialog with the given file name except you have controlled the name on the server.
0
 
LVL 10

Expert Comment

by:dij8
ID: 12302723
Glad I could help.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now