1

我在 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
4

1 回答 1

0

在 Adob​​e Acrobat 中启动 PDF,转到文件、属性并单击初始视图选项卡。在这里,您可以设置人们打开此特定 PDF 时的默认视图,听起来像是选中了“以全屏模式打开”。

于 2010-01-27T21:32:55.947 回答