Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用FileStream将字节数组附加到pdf文件c#asp.net_C#_Asp.net_Pdf_Byte_Filestream - Fatal编程技术网

使用FileStream将字节数组附加到pdf文件c#asp.net

使用FileStream将字节数组附加到pdf文件c#asp.net,c#,asp.net,pdf,byte,filestream,C#,Asp.net,Pdf,Byte,Filestream,我在asp.net web应用程序中工作。我试图使用FileStream将字节数组附加到pdf文件中,并希望结果为包含所有字节数组的pdf文件。但只获取保存在pdf中的最后一个字节数组。我不想使用任何外部库 以下是我附加字节的代码: public void AppendByteToFile(byte[] renderedBytes) { string path = Server.MapPath("~/PrintImages/file1.pdf"); var str

我在asp.net web应用程序中工作。我试图使用FileStream将字节数组附加到pdf文件中,并希望结果为包含所有字节数组的pdf文件。但只获取保存在pdf中的最后一个字节数组。我不想使用任何外部库

以下是我附加字节的代码:

public void AppendByteToFile(byte[] renderedBytes)
{
        string path = Server.MapPath("~/PrintImages/file1.pdf");
        var stream = new FileStream(path, FileMode.Append);
        stream.Seek(0, SeekOrigin.End);
        if (stream.Length==stream.Position)
        {
            stream.Write(renderedBytes, 0, renderedBytes.Length);
            stream.Close();
        }
}   
其中,
renderBytes
是本地报告的rdlc对象,呈现为pdf格式,如下所示

byte[] renderedBytes = report.Render("PDF", deviceInfo);

谢谢

您知道添加一些
字节[]
会使PDF无效吗?除非您添加的
byte[]
包含ISO 32000-1第7.5.6节规定的增量更新,但普通PDF(如您的rdlc本地报告呈现为PDF)不是此类更新。请回复。我不知道您提供的有关增量更新的信息。考虑到这些信息,我猜我想做的是错误的。如果不使用任何外部库,您的任务就相当复杂,不像连接那么简单。