我有一个存储为的PDF列表list<byte[]>
。我尝试使用PDFsharp连接所有这些PDF文件,但是在我进行操作后,我得到了具有正确页数的PDF,但是所有页面都是空白的。看起来我丢失了一些标头或其他内容,但找不到位置。
我的代码:
PdfDocument output = new PdfDocument();
try
{
foreach (var report in reports)
{
using (MemoryStream stream = new MemoryStream(report))
{
PdfDocument input = PdfReader.Open(stream, PdfDocumentOpenMode.Import);
foreach (PdfPage page in input.Pages)
{
output.AddPage(page);
}
}
}
if (output.Pages.Count <= 0)
{
throw new Exception("Empty Document");
}
MemoryStream final = new MemoryStream();
output.Save(final);
output.Close();
return final.ToArray();
}
catch (Exception e)
{
throw new Exception(e.ToString());
}
我想将其返回,byte[]
因为稍后会使用它们:
return File(report, System.Net.Mime.MediaTypeNames.Application.Octet, "test.pdf");
这将返回具有正确页数的PDF,但全部为空白。
您在注释中告诉您这些文件来自SSRS。
较旧的PDFsharp版本需要特殊的SSRS设置:
对于ReportExecutionService对象上Render方法的DeviceSettings参数,请传递以下值:
theDeviceSettings = "<DeviceInfo><HumanReadablePDF>True</HumanReadablePDF></DeviceInfo>";
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句