[英]How to convert a stream to PdfDocument in PDFsharp
Everywhere I get examples of creating PdfDocument
like this:到处我都会得到这样创建
PdfDocument
的示例:
PdfDocument document = PdfReader.Open(fiePath, PdfDocumentOpenMode.Import);
But I don't have the path of file.但我没有文件的路径。 I want to convert
Stream
to PdfDocument
.我想将
Stream
转换为PdfDocument
。 I tried this:我试过这个:
PdfDocument document = new PdfDocument(stream);
but it always gives 0
as PageCount
and PageSize
.但它总是给出
0
作为PageCount
和PageSize
。
PdfReader.Open
can be invoked with a filename or with a stream.可以使用文件名或
PdfReader.Open
调用 PdfReader.Open。
What you tried ( new PdfDocument(stream)
) creates a new and empty document that can be written to the stream by invoking Save()
without parameter.您尝试的内容(
new PdfDocument(stream)
)创建了一个新的空文档,可以通过调用不带参数的Save()
将其写入 stream。 This creates a document, but does not open it.这会创建一个文档,但不会打开它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.