Internet Explorer(v 6、7、8、9)でAdobe Reader X(バージョン10.0。*)を使用してPDFを開く際に既知の問題があります。ブラウザウィンドウが空の灰色の画面で読み込まれます(リーダーツールバーもありません)。Firefox、Chrome、またはAdobe Reader10.1。*で完全に正常に動作します。
私はいくつかの回避策を発見しました。たとえば、[更新]をクリックすると、ドキュメントが正しく読み込まれます。Adobe Reader 10.1。*にアップグレードするか、9。*にダウングレードすると、問題も修正されます。
ただし、これらのソリューションはすべて、ユーザーがそれを理解する必要があります。私のユーザーのほとんどは、この灰色の画面を見るのに非常に混乱し、PDFファイルを非難し、Webサイトが壊れていると非難することになります。正直なところ、私が問題を調査するまで、私もPDFを非難しました!
だから、私は私のユーザーのためにこの問題を修正する方法を見つけようとしています。
「PDFのダウンロード」リンク(Content-Disposition
ヘッダーをattachment
ではなくに設定するinline
)を提供することを検討しましたが、これらのPDFファイルをブラウザーに表示したいので、私の会社はそのソリューションをまったく好みません。
他の誰かがこの問題を経験しましたか?
考えられる解決策または回避策は何ですか?
エンドユーザーがAdobeReaderの設定を変更したり、更新を自動的にインストールしたりする方法を知っているとは思えないので、エンドユーザーにとってシームレスなソリューションを本当に望んでいます。
これが恐ろしい灰色の画面です:
編集:スクリーンショットがファイルサーバーから削除されました!ごめん!
画像は通常のツールバーを備えたブラウザウィンドウでしたが、背景は灰色で、UIはまったくありませんでした。
背景情報:
次の情報は私の問題に関連しているとは思いませんが、参照用に含めます。
これはASP.NET MVCアプリケーションであり、jQueryを使用できます。
PDFファイルへのリンクtarget=_blank
は、新しいウィンドウで開くようになっています。
PDFファイルはオンザフライで生成されており、すべてのコンテンツヘッダーが適切に設定されています。.pdf
URLには拡張子は含まれていませんが、有効なファイル名と設定でcontent-disposition
ヘッダーを設定しています。 .pdf
inline
編集:これは私がPDFファイルを提供するために使用しているソースコードです。
まず、コントローラーのアクション:
public ActionResult ComplianceCertificate(int id){
byte[] pdfBytes = ComplianceBusiness.GetCertificate(id);
return new PdfResult(pdfBytes, false, "Compliance Certificate {0}.pdf", id);
}
そして、これがActionResult(PdfResult
、inherits System.Web.Mvc.FileContentResult
)です:
using System.Net.Mime;
using System.Web.Mvc;
/// <summary>
/// Returns the proper Response Headers and "Content-Disposition" for a PDF file,
/// and allows you to specify the filename and whether it will be downloaded by the browser.
/// </summary>
public class PdfResult : FileContentResult
{
public ContentDisposition ContentDisposition { get; private set; }
/// <summary>
/// Returns a PDF FileResult.
/// </summary>
/// <param name="pdfFileContents">The data for the PDF file</param>
/// <param name="download">Determines if the file should be shown in the browser or downloaded as a file</param>
/// <param name="filename">The filename that will be shown if the file is downloaded or saved.</param>
/// <param name="filenameArgs">A list of arguments to be formatted into the filename.</param>
/// <returns></returns>
[JetBrains.Annotations.StringFormatMethod("filename")]
public PdfResult(byte[] pdfFileContents, bool download, string filename, params object[] filenameArgs)
: base(pdfFileContents, "application/pdf")
{
// Format the filename:
if (filenameArgs != null && filenameArgs.Length > 0)
{
filename = string.Format(filename, filenameArgs);
}
// Add the filename to the Content-Disposition
ContentDisposition = new ContentDisposition
{
Inline = !download,
FileName = filename,
Size = pdfFileContents.Length,
};
}
protected override void WriteFile(System.Web.HttpResponseBase response)
{
// Add the filename to the Content-Disposition
response.AddHeader("Content-Disposition", ContentDisposition.ToString());
base.WriteFile(response);
}
}