嘿,在我的asp应用程序创建PDF文件并将其保存在App_Data文件夹服务器上。接下来我想打开这个文件,用户可以打印。
Hey, In my asp application I create pdf file and save it in App_Data folder on server. Next I want to open this file that user can print it.
如何打开浏览器中的这个文件?发送的HTTP头等等?有人有一些例子?
How to open this file in browser ? Send it in http header etc ? Someone have some examples?
请帮助;)
推荐答案您可以将文件保存在文件夹中,然后给用户一个页面,在这里,他们可以点击链接来下载文件。只记得在文件中创建一个唯一的名称(使用GUID),否则用户将下载对方的文件。
you could save the file in a folder and then give the user a page where they can click on a link to download the file. just remember to create a unique name for the file (using guid) otherwise users will download each other's files.
您也可以在响应返回文件。以下code是返回一个Excel文件,但可以很容易地修改PDF。
you could also return the file in the response. the following code is for returning an excel file, but can be easily modified for pdf.
Response.ContentType = "application/vnd.ms-excel"; Response.AppendHeader("Content-Disposition", string.Format("attachment; filename={0}", fileName)); Response.TransmitFile(Server.MapPath(string.Format("{0}/{1}", BasePath, fileName)));更多推荐
从服务器打开文件并发送到浏览器
发布评论