【发布时间】:2011-02-18 10:26:29
【问题描述】:
如何使用 itextsharp 在内存流中创建 PDF 而不是物理文件。
下面的代码正在创建实际的 pdf 文件。
相反,我如何创建一个 byte[] 并将其存储在 byte[] 中,以便我可以通过函数返回它
using iTextSharp.text;
using iTextSharp.text.pdf;
Document doc = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35);
PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream("c:\\Test11.pdf", FileMode.Create));
doc.Open();//Open Document to write
Paragraph paragraph = new Paragraph("This is my first line using Paragraph.");
Phrase pharse = new Phrase("This is my second line using Pharse.");
Chunk chunk = new Chunk(" This is my third line using Chunk.");
doc.Add(paragraph);
doc.Add(pharse);
doc.Add(chunk);
doc.Close(); //Close document
【问题讨论】:
-
使用内存流加密PDF,我们可以参考aspsnippets.com/Articles/…
标签: c# itextsharp