VintaSoft Imaging .NET SDK 14.0: Documentation for .NET developer
Vintasoft.Imaging.Pdf.Tree Namespace / PdfPageCollection Class / Add Methods / Add(VintasoftImage) Method
Syntax Example Requirements SeeAlso
In This Topic
    Add(VintasoftImage) Method (PdfPageCollection)
    In This Topic
    Adds new page with specified image into the PdfPageCollection.
    Syntax

    Parameters

    image
    Background image of the page.

    Return Value

    Added PdfPage.
    Example

    Here is an example that shows how to add a new image-only page to a PDF document:

    
    ''' <summary>
    ''' Adds new image-only PDF page into a PDF document.
    ''' </summary>
    ''' <param name="pdfFileName">The filename of PDF document.</param>
    ''' <param name="image">The image of the page.</param>
    Public Shared Sub AddImageOnlyPdfPageToPdfDocument(pdfFileName As String, image As Vintasoft.Imaging.VintasoftImage)
        ' 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 page with specified image into collection of pages
            pages.Add(image)
    
            ' save changes to a file
            document.SaveChanges()
        End Using
    End Sub
    
    
    
    /// <summary>
    /// Adds new image-only PDF page into a PDF document.
    /// </summary>
    /// <param name="pdfFileName">The filename of PDF document.</param>
    /// <param name="image">The image of the page.</param>
    public static void AddImageOnlyPdfPageToPdfDocument(
        string pdfFileName, 
        Vintasoft.Imaging.VintasoftImage image)
    {
        // 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 page with specified image into collection of pages
            pages.Add(image);
    
            // 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