c# - 从共享路径读取 PDF 文件并使用 iframe 在表格中显示
问题描述
在一个 asp.net Web 应用程序中,我使用下面的代码从共享路径读取 PDF 文件,并td
使用 iframe 在表格标签中显示它。这样它就可以像缩略图/预览一样显示 pdf。这适用于小型 pdf 文件大小。但是对于 pdf 文件大小 > 25mb(大约),iframe 显示为空。
ImpersonationHelper.Impersonate(ConfigurationManager.AppSettings["Domain"], ConfigurationManager.AppSettings["UserName"], ConfigurationManager.AppSettings["Password"], delegate
{
FileBuffer = System.IO.File.ReadAllBytes(filepath);
if (FileBuffer != null)
{
if (filepathnew.Contains("pdf"))
{
string base64String = Convert.ToBase64String(FileBuffer, 0, FileBuffer.Length);
pdfUrl = "data:application/pdf;base64," + base64String;
}
}
});
string pdfSource = String.Empty;
pdfSource = "<iframe src=" + pdfUrl + " visible='false' style='overflow:hidden' width='400' height='400' scrolling='no' type='application/pdf' id='pdfPreview'></iframe>";
StringBuilder table = new StringBuilder();
table.Append("<td >" + pdfSource1 + "</td>");
解决方案
推荐阅读
- reactjs - 如何在主页上呈现登录表单
- python - 如何通过查找列表和熊猫中其他列之间的最佳匹配来填充列?
- python - 更改字典列表中的元组
- maven - 如何使用 maven 程序集插件进行 unix 行尾
- java - 如果 Selenium 中出现弹出窗口,我如何使用 if 条件单击特定按钮
- python - 用另一个列表中的值更新字典中的值
- sql - 找出使用 LIKE 查询时匹配的模式?
- angular - ViewContainerRef 实现源码
- python - 运行 pytest 时,忽略 addopts 中的标志
- python - 对于某些可变对象,python“is”等效性令人困惑