我遇到了在asp.net中在iframe中显示PDF的问题。当pdf显示时,它显示没有允许用户缩放和打印的Acrobat工具栏。这给我们的客户带来了很大的麻烦,因为他们无法读取大小相当的PDF。如果您尝试将Acrobat设置为不在浏览器中显示PDF并浏览到该页面,则会收到一条消息,指出它正在尝试以全屏模式打开它。任何想法如何使我不能从代码中做到这一点?下面是我用于将PDF流式传输到浏览器的代码:
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
答案 0 :(得分:0)
在Adobe Acrobat中启动PDF,转到“文件”,“属性”,然后单击“初始视图”选项卡。在这里,您可以设置人们打开此特定PDF时的默认视图,它听起来像是“在全屏模式下打开”。