Exemplo n.º 1
0
        public static void MergePdf()
        {
            using (MemoryStream stream = new MemoryStream())
            {
                PdfDocument pdfDoc = new PdfDocument(new PdfWriter(stream));
                iText.Kernel.Utils.PdfMerger merger = new iText.Kernel.Utils.PdfMerger(pdfDoc);

                foreach (byte[] pdf in Pdfs)
                {
                    PdfDocument currentPdf = new PdfDocument(new PdfReader(new MemoryStream(pdf)));
                    merger.Merge(currentPdf, 1, currentPdf.GetNumberOfPages());
                    currentPdf.Close();
                }

                merger.Close();
                pdfDoc.Close();

                FinalMergedPdfURL = Format + Convert.ToBase64String(stream.ToArray());
            }

            IsSubmitComplete = true;
            IsMergeComplete  = true;
        }