问题描述
我真的很喜欢C#中的pdfclown,但是我想从byte []数组或文件流中打开pdf。我没有找到有关pdfclown的任何示例。有人可以帮忙吗?
I am really liking pdfclown in c# but I would like to open a pdf from a byte[] array or filestream. I have not found any examples of this for pdfclown. Could anyone help?
示例如下:
使用(org.pdfclown.files.File文件=新的org.pdfclown.bytes.IInputStream(bytes))
{
using (org.pdfclown.files.File file = new org.pdfclown.bytes.IInputStream(bytes)){
...
}
...}
谢谢
推荐答案
这是从字节数组中打开文件的正确方法:
This is the right way to open a file from a byte array:
var bytes = . . .;
using (var file = new org.pdfclown.files.File(new org.pdfclown.bytes.Buffer(bytes)))
{
}
如果您(0.1.2.1版或更高版本)或下载下一个版本,您甚至可以使用以下超简单的构造函数:
If you check out PDF Clown from its repository (version 0.1.2.1 or later) or download the next release, you can even use this ultra-simple constructor:
byte[] bytes = . . .;
using (var file = new org.pdfclown.files.File(bytes))
{
}
,或者对于System.IO.Stream:
or, in case of System.IO.Stream:
System.IO.Stream stream = . . .;
using (var file = new org.pdfclown.files.File(stream))
{
}
如果您具有纯文件系统路径,则为您的构造函数:
If you have a plain file system path, this is your constructor:
string filename = . . .;
using (var file = new org.pdfclown.files.File(filename))
{
}
这篇关于在C#中使用pdfclown从流中打开pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!