Combine two (or more) PDF's

后端 未结 17 1489
梦毁少年i
梦毁少年i 2020-12-04 07:26

Background: I need to provide a weekly report package for my sales staff. This package contains several (5-10) crystal reports.

Problem:

17条回答
  •  时光说笑
    2020-12-04 07:49

    I combined the two above, because I needed to merge 3 pdfbytes and return a byte

    internal static byte[] mergePdfs(byte[] pdf1, byte[] pdf2,byte[] pdf3)
            {
                MemoryStream outStream = new MemoryStream();
                using (Document document = new Document())
                using (PdfCopy copy = new PdfCopy(document, outStream))
                {
                    document.Open();
                    copy.AddDocument(new PdfReader(pdf1));
                    copy.AddDocument(new PdfReader(pdf2));
                    copy.AddDocument(new PdfReader(pdf3));
                }
                return outStream.ToArray();
            } 
    

提交回复
热议问题