PDF를 바이트 배열로 읽고이를 사용하십시오. awright18이 말했듯이, 핸들러 (.ashx)에서 이것을하십시오. 이런 식으로 뭔가 :
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class MapHandler : IHttpHandler, IReadOnlySessionState
{
public void ProcessRequest(HttpContext context) {
CreateImage(context);
}
private void CreateImage(HttpContext context) {
string documentFullname = // Get full name of the PDF you want to display...
if (File.Exists(documentFullname)) {
byte[] buffer;
using (FileStream fileStream = new FileStream(documentFullname, FileMode.Open, FileAccess.Read, FileShare.Read))
using (BinaryReader reader = new BinaryReader(fileStream)) {
buffer = reader.ReadBytes((int)reader.BaseStream.Length);
}
context.Response.ContentType = "application/pdf";
context.Response.AddHeader("Content-Length", buffer.Length.ToString());
context.Response.BinaryWrite(buffer);
context.Response.End();
} else {
context.Response.Write("Unable to find the document you requested.");
}
}
public bool IsReusable {
get {
return false;
}
}
나는 SO 유용 여기 this thread을 발견하지만, 위의 당신을 위해 작동합니다.
파일 이름을 알고 싶지 않습니까? – awright18
사용자가 PDF를 저장하는 방법을 너무 많이 알 필요가 없습니다! –
어쩌면 PDF 파일을 저장하도록 선택하면 파일 이름을 표시하는 것이 좋을 것입니다 ... 나는 그것에 대해 thougth하지 않았습니다. – sergiogx