У меня проблема с отображением PDF в iframe на asp.net. Когда отображается 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