如何将字节数组加载到PDF文档中?

如何将字节数组加载到PDF文档中?

问题描述:

我试图将字节数组加载到pdf文档中,但是我收到了一个错误,包含字母格式的数组,我需要在发送邮件之前以pdf格式预览。



我尝试过:



Im trying to load array of bytes into pdf document but I got an error, the array containing letter format which I need to preview in pdf before sending it in a mail.

What I have tried:

byte[] bytes = GetFileBytes(fileStream);
            Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 10f);
            PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
            pdfDoc.Open();
           //how should I load the bytes
            pdfDoc.Close();
            Response.ContentType = "application/pdf";
            Response.AddHeader("Content-Disposition", "attachment;filename=preview.pdf");
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Write(pdfDoc);
            Response.End();