VintaSoft Imaging .NET SDK 15.1: Documentation for .NET developer
Vintasoft.Imaging.Pdf.Tree Namespace / PdfPageCollection Class / AddRange(PdfPage[]) Method
Syntax Example Requirements SeeAlso
In This Topic
AddRange(PdfPage[]) Method (PdfPageCollection)
In This Topic
Appends a range of pages to the PdfPageCollection.
Syntax
'Declaration

Public Sub AddRange( _
ByVal pages
Array of pages to add.
() As PdfPage _
)
public void AddRange(
PdfPage[] pages
)

Parameters

pages
Array of pages to add.
Example

Here is an example that shows how to copy all pages of PDF document and add the pages at the end of another PDF document:


''' <summary>
''' Copies all pages of source PDF document to the end of destination PDF document.
''' </summary>
''' <param name="srcPdfFileName">The filename of source PDF document.</param>
''' <param name="destPdfFileName">The filename of destination PDF document.</param>
Public Shared Sub CopyPagesFromOnePdfDocumentToAnother(srcPdfFileName As String, destPdfFileName As String)
    ' open source PDF document
    Using srcDocument As New Vintasoft.Imaging.Pdf.PdfDocument(srcPdfFileName)
        ' open destination PDF document
        Using destDocument As New Vintasoft.Imaging.Pdf.PdfDocument(destPdfFileName)
            ' get pages of source PDF document as array
            Dim srcDocumentPages As Vintasoft.Imaging.Pdf.Tree.PdfPage() = srcDocument.Pages.ToArray()

            ' append the array of PDF pages to the destination PDF document
            destDocument.Pages.AddRange(srcDocumentPages)

            ' save changes to a file
            destDocument.SaveChanges()
        End Using
    End Using
End Sub


/// <summary>
/// Copies all pages of source PDF document to the end of destination PDF document.
/// </summary>
/// <param name="srcPdfFileName">The filename of source PDF document.</param>
/// <param name="destPdfFileName">The filename of destination PDF document.</param>
public static void CopyPagesFromOnePdfDocumentToAnother(string srcPdfFileName, string destPdfFileName)
{
    // open source PDF document
    using (Vintasoft.Imaging.Pdf.PdfDocument srcDocument = 
        new Vintasoft.Imaging.Pdf.PdfDocument(srcPdfFileName))
    {
        // open destination PDF document
        using (Vintasoft.Imaging.Pdf.PdfDocument destDocument = 
            new Vintasoft.Imaging.Pdf.PdfDocument(destPdfFileName))
        {
            // get pages of source PDF document as array
            Vintasoft.Imaging.Pdf.Tree.PdfPage[] srcDocumentPages = srcDocument.Pages.ToArray();

            // append the array of PDF pages to the destination PDF document
            destDocument.Pages.AddRange(srcDocumentPages);

            // save changes to a file
            destDocument.SaveChanges();
        }
    }
} 

Requirements

Target Platforms: .NET 10; .NET 9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

See Also