标签: writeallbytes

字节数组到pdf

我正在尝试将存储在sql列中的文件的内容转换为pdf.

我使用以下代码:

byte[] bytes;
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
bf.Serialize(ms, fileContent);
bytes = ms.ToArray();
System.IO.File.WriteAllBytes("hello.pdf", bytes);
Run Code Online (Sandbox Code Playgroud)

生成的pdf在某种意义上是腐败的,当我在notepad ++中打开pdf时,我看到一些垃圾标题(无论fileContent如何都是相同的).垃圾标题是NUL SOH NUL NUL NUL ....

c# file writeallbytes

30
推荐指数
1
解决办法
8万
查看次数

标签 统计

c# ×1

file ×1

writeallbytes ×1