使用字节数组c#/asp.net创建PDF文件

使用字节数组c#/asp.net创建PDF文件,asp.net,pdf-generation,Asp.net,Pdf Generation,有人能告诉我如何使用字节数组创建PDF文件吗?我试过这两种方法,但没有成功 1) System.IO.File.WriteAllBytes(filePath, bytesArray); 2) using (System.IO.Stream stream = new System.IO.FileStream(filePath, System.IO.FileMode.Create)) { stream.Write(bytesArray, 0, bytesArray.Length);

有人能告诉我如何使用字节数组创建PDF文件吗?我试过这两种方法,但没有成功

1) System.IO.File.WriteAllBytes(filePath, bytesArray);
2) using (System.IO.Stream stream = new System.IO.FileStream(filePath, System.IO.FileMode.Create))
   {
     stream.Write(bytesArray, 0, bytesArray.Length);
   }
或者我需要使用任何第三方组件来执行相同的操作


任何帮助都将不胜感激。。。提前谢谢。

您可以尝试类似的方法-未经测试

使用
Response.Clear();
    Response.ContentType = "application/pdf";
    Response.AppendHeader("Content-Disposition", "inline;filename=data.pdf");
Response.BufferOutput = true; byte[] pdf; Response.AddHeader("Content-Length", response.Length.ToString());
 Response.BinaryWrite(pdf);
 Response.End();