这是我的情况,我有一个数据模型列表,它将给定的PDF模板填充到一个大的pdf中,并显示在网页上供客户端打印文件 . (没有本地副本) . 我使用kuujinbo的例子https://stackoverflow.com/a/8525007/5533303但由于某种原因我可以't let the memory stream to bind when i am going to display the pdf on page. (the error is can't读取封闭的内存流 . )我的系统环境是带有最新itextsharp的MVC 5 .
20151107更新:找到原因 . 总体代码是正确的但在循环结束时我应该把byteInfo = Masterstream.ToArray();在smartcopy之外使用但在文档内部使用 . 然后创建一个新的内存字符串以捕获byteinfo并返回到视图 .
List PrintList = ( List )Session["GetDAta"];
BaseFont baseChineseFont = BaseFont.CreateFont(@"~~~~~~~~~",
BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
MemoryStream Masterstream = new MemoryStream();
byte[] byteInfo;
using (Document document = new Document())
{
using (PdfSmartCopy copy = new PdfSmartCopy(document, Masterstream))
{
document.Open();
foreach (Datamodel childnode in PrintList)
{
PdfReader pdfReader = ne