2010-01-27 180 views
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 

回答

0

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

+0

我尝试设置PDF选项,当它生成不使用全屏模式,但它并没有改变一切。无论如何,从Response.Write强制这个选项? – bechbd 2010-01-28 17:32:20

+0

创建PDF后,在Acrobat中打开它。全屏选项是否被选中? – 2010-01-29 14:08:42

+0

我没有Acrobat的完整版本,所以我看不到。你能以Acrobat Reader的方式看到这个吗? – bechbd 2010-01-29 18:46:16