我真的很喜欢pdfclown在C#但我想打开一个字节[]数组或文件流的PDF。我还没有发现任何关于pdfclown的例子。谁能帮忙?从c#流使用pdfclown打开pdf#
一个例子是这样的:
使用(org.pdfclown.files.File文件=新org.pdfclown.bytes.IInputStream(字节)) {
... }
谢谢
我真的很喜欢pdfclown在C#但我想打开一个字节[]数组或文件流的PDF。我还没有发现任何关于pdfclown的例子。谁能帮忙?从c#流使用pdfclown打开pdf#
一个例子是这样的:
使用(org.pdfclown.files.File文件=新org.pdfclown.bytes.IInputStream(字节)) {
... }
谢谢
这是打开从一个字节数组文件的正确方法:
var bytes = . . .;
using (var file = new org.pdfclown.files.File(new org.pdfclown.bytes.Buffer(bytes)))
{
}
如果check out PDF Clown from its repository(0.1.2.1或更高版本)或下载下一个版本中,你甚至可以用这个超简单的构造:
byte[] bytes = . . .;
using (var file = new org.pdfclown.files.File(bytes))
{
}
,或者在System.IO.Stream的情况下:
System.IO.Stream stream = . . .;
using (var file = new org.pdfclown.files.File(stream))
{
}
如果你有一个普通的文件系统路径,这是你的构造:
string filename = . . .;
using (var file = new org.pdfclown.files.File(filename))
{
}
我使用pdfclown论坛找到了这个问题的答案。我已经适应了我的需要。 enter link description here
byte[] bytes = io.File.ReadAllBytes(@filename);
using (var ms = new io.MemoryStream(bytes))
{
using (org.pdfclown.bytes.IInputStream i = new org.pdfclown.bytes.Stream(ms))
{
using (org.pdfclown.files.File file = new org.pdfclown.files.File(i))
{
}
}
}
斯特凡诺,这真是棒极了!谢谢! – Dave 2015-03-06 15:13:09