I'm currently working on some reports and need to append several reports in one PDF. In order to do so I'm using ReportViewer to get the reports in different byte[]. Once I have all the reports in a List I proceed to join them using the following method
byte[] appendBuffers(List<byte[]> arrays)
{
List<byte> byteList = new List<byte>();
for (int i = 0; i < arrays.Count; i++)
{
for (int j = 0; j < arrays[i].Length; j++)
{
byteList.Add(arrays[i][j]);
}
}
return byteList.ToArray();
}
Now... once I'm done the resulting byte[] has all the data however when I display the reports on my website I only get the last report to appear on the screen. Any ideas?
You can't merge PDFs by just merging the file bytes. PDFs have an internal format. Use a PDF library such as Foxit or PDFSAM to merge PDF pages into a single file.