【问题标题】:Itextsharp created PDF fileItextsharp 创建的 PDF 文件
【发布时间】:2016-11-16 21:48:18
【问题描述】:

然而,我使用 itextsharp 库来生成和填充 PDF 文件;我遇到的问题是,当您在 Chrome 中打开其中一些文件时,我会得到下面的图像,但它在 IE 中确实可以正常工作

【问题讨论】:

  • 我认为是内容类型错误相关..您需要使用application/pdf返回有效的内容类型。
  • 我不确定我是否理解您使用 application/pdf 的意思,因为我已经指定了文件类型。一定有我在这里遗漏的东西或与 Chrome 有关的东西......
  • 好的,你这样指定响应的内容类型:Response.ContentType = "application/pdf";
  • 是的,我已经在下面看到了。 if (strExt[strExt.Length-1] == "pdf") { Response.ContentType = "application/pdf"; } Response.AddHeader("Content-Disposition", "inline;filename=" + objectreader["document"]);响应缓冲区=真; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.BinaryWrite(pdfbytes);
  • 你需要把这个:Response.ContentType = "Application/pdf"; Response.TransmitFile(pathtofile);

标签: asp.net itext


【解决方案1】:

我找到了自己的答案,事实证明,当我将文件保存到 Db 时,我没有将 .pdf 作为扩展名添加到文件中,这就是它出现这种情况的原因。 因为表单数据先保存,然后再检索。 感谢您的回复。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-23
    • 1970-01-01
    • 2021-03-26
    • 1970-01-01
    • 2016-01-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多