asp.netのiframeでPDFを表示する際に問題が発生しました。PDFが表示されると、ユーザーがズームおよび印刷できるAcrobatツールバーなしで表示されます。これは、PDFをそのサイズで読み取ることができないため、お客様に大きな問題を引き起こしています。ブラウザに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