使用LINQ合并几个PDF

时间:2019-02-28 13:26:54

标签: c# linq

我找到了这个link

我想将多个pdf合并为一个

我的问题如何使用LINQ进行相同操作?

if (pdfFileContentBytes.Length >=2)
{
    byte[] a = pdfFileContentBytes[0];

    for (int i = 1; i < pdfFileContentBytes.Length; i++)
    {
        using (var library = DocLib.Instance)
        {
            byte[] b = pdfFileContentBytes[i];
            byte[] temp = a;

           a = library.Merge(temp, b);
        }
    }
    System.IO.File.WriteAllBytes("myfile4.pdf", a);

    return a;
}

1 个答案:

答案 0 :(得分:0)

if (pdfFileContentBytes.Length >=2)
{
      var a = pdfFileContentBytes[0];

         using (DocLib.Instance)
            pdfFileContentBytes.Skip(1).ForEach(b => a= 
        DocLib.Instance.Merge(a,b));
     return a
}