VintaSoft Imaging .NET SDK 14.0: Documentation for .NET developer
Vintasoft.Imaging.Pdf.Tree Namespace / PdfPageCollection Class / Add Methods / Add(PdfPage) Method
Syntax Example Requirements SeeAlso
In This Topic
    Add(PdfPage) Method (PdfPageCollection)
    In This Topic
    Adds the PdfPage at specified index into the PdfPageCollection.
    Syntax
    'Declaration
    
    Public Overloads Sub Add( _
    ByVal page
    The PdfPage to add.
    As PdfPage _
    )
    public void Add(
    PdfPage page
    )
    public: void Add(
    PdfPage* page
    )
    public:
    void Add(
    PdfPage^ page
    )

    Parameters

    page
    The PdfPage to add.
    Example

    Here is an example that shows how to copy the first page of PDF document and add the page at the end of the same PDF document:

    
    ''' <summary>
    ''' Copies the first page of PDF document to the end of PDF document.
    ''' </summary>
    ''' <param name="pdfFileName">The filename of PDF document.</param>
    Public Shared Sub CopyFirstPdfPageToEndOfPdfDocument(pdfFileName As String)
        ' open PDF document
        Using document As New Vintasoft.Imaging.Pdf.PdfDocument(pdfFileName)
            ' get the collection of pages of PDF document
            Dim pages As Vintasoft.Imaging.Pdf.Tree.PdfPageCollection = document.Pages
    
            ' add first page to the end of PDF document
            pages.Add(pages(0))
    
            ' save changes to a file
            document.SaveChanges()
        End Using
    End Sub
    
    
    
    /// <summary>
    /// Copies the first page of PDF document to the end of PDF document.
    /// </summary>
    /// <param name="pdfFileName">The filename of PDF document.</param>
    public static void CopyFirstPdfPageToEndOfPdfDocument(string pdfFileName)
    {
        // open PDF document
        using (Vintasoft.Imaging.Pdf.PdfDocument document = 
            new Vintasoft.Imaging.Pdf.PdfDocument(pdfFileName))
        {
            // get the collection of pages of PDF document
            Vintasoft.Imaging.Pdf.Tree.PdfPageCollection pages = document.Pages;
    
            // add first page to the end of PDF document
            pages.Add(pages[0]);
    
            // save changes to a file
            document.SaveChanges();
        }
    }
    
    

    Requirements

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

    See Also