在一个pdf文件中合并两个字节数组 [英] Merge two array of bytes in one pdf file
本文介绍了在一个pdf文件中合并两个字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的,
我有两个字节数组,每个字节代表一页的报告。
i想要合并他们并生成两页的pdf报告。
我该怎么做?
我尝试了什么:
byte [ ] bytes = ReportViewer1.LocalReport.Render( PDF, null , out mimeType, out 编码, out extension1, out streamIds, out 警告);
byte [] bytes1 = ReportViewer2.LocalReport.Render( PDF, null , out mimeType, out 编码, out extension1, out streamIds, out 警告);
byte [] newByteArray2 = bytes.Concat(bytes1).ToArray();
System.IO.File.WriteAllBytes( C://MyNewReport.pdf,newByteArray2);
解决方案
只是连接字节数组不会有用 - DPF是一种容器格式,所以只需将两个容器抽薹在一起就不会产生一个大容器。除了将两袋糖装在一起之外,还会产生一个装满糖的两倍大袋...
看看这个:使用iTextSharp在C#中拆分和合并PDF文件 [ ^
Dears,
I have two array of bytes each one of them represents a report of one page.
i want to to merge them and generates a pdf report of two pages.
how can i do that?
What I have tried:
byte[] bytes = ReportViewer1.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension1, out streamIds, out warnings);
byte[] bytes1 = ReportViewer2.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension1, out streamIds, out warnings);
byte[] newByteArray2 = bytes.Concat(bytes1).ToArray();
System.IO.File.WriteAllBytes("C://MyNewReport.pdf", newByteArray2);
解决方案
Just concatenating byte arrays won't do anything useful - DPF is a "container" format, so just "bolting" two containers together doesn't produce one big container. Any more than stapling two bags of sugar together would create a bigger bag full of twice as much sugar...
Have a look at this: Splitting and Merging PDF Files in C# Using iTextSharp[^]
这篇关于在一个pdf文件中合并两个字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文