我正在尝试使用字节数组生成 pdf 文件。使用的代码是:
Public Sub SavePdf(ByVal bytes() As Byte)
Dim filePath As String = HttpContext.Current.Server.MapPath("~/ClientBin/file1.pdf")
Dim byteData() As Byte = bytes
File.WriteAllBytes(filePath,byteData)
End Sub
字节数组是使用richEditControl 生成的。代码如下:
Public Sub generateByte_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim ms As MemoryStream = New MemoryStream()
ms.Flush()
richEditControl1.SaveDocument(ms, DocumentFormat.Rtf)
client.SavePdf(ms.ToArray())
MessageBox.Show("FileSaved")
End Sub
这样生成的文件打不开。