从 System.IO.Stream 对象创建 pdf 文档?
我有 Stream 对象,其中包含我想要在 PDF 文档中显示的数据。
如何从该 Stream 对象创建并保存 PDF 文档? (Stream对象是使用MigraDoc工具创建的)
I have Stream object that contains data that i want to show in PDF document.
How do i create and Save PDF document from that Stream object? (The Stream object is created using MigraDoc tool)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想你可能会感到困惑。 MigraDoc 创建 Pdf 文档。因此,如果您有来自 MigraDoc 的流(来自它的 PdfDocument 对象),我猜测将流保存到磁盘作为“document.pdf”将是最佳选择。
请参阅 Jon Skeets 对此的回答:
如何保存流到 C# 中的文件?
请记住,流只是二进制数据。因此,当您想要读取和写入该数据时,您可以使用 System.IO 将流读取或写入某个位置,无论是磁盘、内存还是网络传输。
我会查看 MigraDoc 示例以获取更多信息:
http://www.pdfsharp.net /wiki/MigraDocSamples.ashx
如果您将其写入 HTTP 输出,那么我将执行以下操作:
I think you may be confused. MigraDoc creates Pdf documents. So if you have a stream from MigraDoc (which comes from it's PdfDocument object) I would guess that saving the stream to disk as "document.pdf" would be the best option.
See Jon Skeets answer to this here:
How do I save a stream to a file in C#?
Remember a stream is simply binary data. So when you want to read and write that data you use System.IO to read or write the stream into some location be it disk, memory or a network transmission.
I would take a look at the MigraDoc samples for more info:
http://www.pdfsharp.net/wiki/MigraDocSamples.ashx
if you are writing this to an HTTP output then I would do as follows: