/// <summary> /// Imports pages of <paramref name="sourceDocument"/> into the current <see cref="PdfDocument"/>. /// </summary> /// <seealso cref="PDFium.FPDF_ImportPages(Types.FPDF_DOCUMENT, Types.FPDF_DOCUMENT, int, int[])"/> public bool Insert(int index, PdfDocument sourceDocument, params int[] srcPageIndices) { bool result = false; if (index <= _pages.Count) { result = PDFium.FPDF_ImportPages(_doc.Handle, sourceDocument.Handle, index, srcPageIndices); if (result) { _pages.InsertRange(index, Enumerable.Repeat <PdfPage>(null, srcPageIndices.Length)); for (int i = index; i < _pages.Count; i++) { if (_pages[i] != null) { _pages[i].Index = i; } } } } else { throw new ArgumentOutOfRangeException(nameof(index)); } return(result); }
/// <summary> /// Imports pages of <paramref name="sourceDocument"/> into the current <see cref="PdfDocument"/>. /// </summary> /// <seealso cref="PDFium.FPDF_ImportPages(Types.FPDF_DOCUMENT, Types.FPDF_DOCUMENT, int, int[])"/> public bool Insert(int index, PdfDocument sourceDocument, params int[] srcPageIndices) { if (index < _pages.Count) { _pages.Insert(index, null); } var result = PDFium.FPDF_ImportPages(_doc.Handle, sourceDocument.Handle, index, srcPageIndices); _pages.InsertRange(index, Enumerable.Repeat <PdfPage>(null, srcPageIndices.Length)); for (int i = index; i < _pages.Count; i++) { if (_pages[i] != null) { _pages[i].Index = i; } } return(result); }