Swap(PdfPage,PdfPage) Method (PdfPageCollection)
Swaps two pages in the collection.
Here is an example that shows how to reorder the pages of PDF document:
''' <summary>
''' Swaps the first and the last pages of PDF document.
''' </summary>
''' <param name="pdfFileName">The filename of PDF document.</param>
Public Shared Sub SwapPages(pdfFileName As String)
' open PDF documnet
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
' get the page count
Dim pagesCount As Integer = pages.Count
' swap the first and the last pages
pages.Swap(0, pagesCount - 1)
' save changes to a file
document.SaveChanges()
End Using
End Sub
/// <summary>
/// Swaps the first and the last pages of PDF document.
/// </summary>
/// <param name="pdfFileName">The filename of PDF document.</param>
public static void SwapPages(string pdfFileName)
{
// open PDF documnet
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;
// get the page count
int pagesCount = pages.Count;
// swap the first and the last pages
pages.Swap(0, pagesCount - 1);
// save changes to a file
document.SaveChanges();
}
}
Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5