public static DocumentWrapper LoadFrom(this DocumentWrapper source, IEnumerable <IPdfContent> pdfs) { source.IsEncrypted = false; MemoryStream ms = null; PdfCopy pdfCopy = null; PdfReader reader = null; try { using (ms = new MemoryStream()) using (pdfCopy = new PdfCopy(source, ms)) { source.Open(); foreach (var item in pdfs) { reader = item.ToPdfContent().GetReader(); source.IsEncrypted = source.IsEncrypted.Value || reader.IsEncrypted(); pdfCopy.AddAllPages(ref reader); reader.Close(); } source.Close(); source.Content = ms.ToDeepCopyArray(); return(source); } } catch (Exception ex) { Debug.WriteLine(ex.Message); Debug.WriteLine(ex.StackTrace); throw; } finally { reader.CloseQuietly(); source.CloseQuietly(); pdfCopy.CloseQuietly(); ms.CloseQuietly(); } }