1
我遇到了在asp.net中的iframe中顯示PDF的問題。當pdf顯示它沒有顯示允許用戶縮放和打印的Acrobat工具欄時顯示。這對我們的客戶造成了很大的麻煩,因爲他們無法閱讀PDF文件的大小。如果您嘗試將Acrobat設置爲不在瀏覽器中顯示PDF並瀏覽到該頁面,則會顯示一條消息,指出它正嘗試以全屏模式打開它。任何想法,我可以做到這一點不從代碼做到這一點?下面是我使用的PDF流式傳輸到瀏覽器的代碼:Acrobat在全屏模式下打開
Public Shared Sub StreamPdfToBrowser(ByVal doc As Document)
Dim Ctx As HttpContext = HttpContext.Current
'// Clear any part of this page that might have already been buffered for output.
Ctx.Response.Clear()
Ctx.Response.ClearHeaders()
'// Tell the browser this is a PDF document so it will use an appropriate viewer.
Ctx.Response.ContentType = doc.DisplayFileType
Ctx.Response.ContentType = "application/pdf"
Ctx.Response.AddHeader("content-type", "application/pdf")
'// IE & Acrobat seam to require "content-disposition" header being in the response. If you don't add it, the doc still works most of the time, but not always.
'// this makes a new window appear:
Response.AddHeader("content-disposition","attachment[inline]; filename=MyPDF.PDF");
Ctx.Response.AddHeader("Content-Length", doc.DisplayFile.Length)
Ctx.Response.AddHeader("Content-Disposition", "inline; filename=E-Sign Specification Report.pdf")
'// TODO: Added by KN to possibly fix UA issue
Ctx.Response.ContentType = "application/pdf"
Ctx.Response.AddHeader("content-type", "application/pdf")
'// Write the PDF stream out
Ctx.Response.BinaryWrite(doc.DisplayFile)
'// Send all buffered content to the client
Ctx.Response.End()
End Sub
我嘗試設置PDF選項,當它生成不使用全屏模式,但它並沒有改變一切。無論如何,從Response.Write強制這個選項? – bechbd 2010-01-28 17:32:20
創建PDF後,在Acrobat中打開它。全屏選項是否被選中? – 2010-01-29 14:08:42
我沒有Acrobat的完整版本,所以我看不到。你能以Acrobat Reader的方式看到這個嗎? – bechbd 2010-01-29 18:46:16