This sample shows how to copy pages from one PDF document to another.
Use PdfDocument.CopyPages method to copy pages to new document. Please note that source document won't be changed.
using System.Diagnostics; namespace BitMiracle.Docotic.Pdf.Samples { public static class CopyPages { public static void Main() { // NOTE: // When used in trial mode, the library imposes some restrictions. // Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx // for more information. PdfDocument pdf = new PdfDocument(@"Sample Data\jfif3.pdf"); // copy third and first pages to a new PDF document (page indexes are zero-based) PdfDocument copy = pdf.CopyPages(new int[] { 2, 0 }); copy.Save("CopyPages.pdf"); copy.Dispose(); pdf.Dispose(); Process.Start("CopyPages.pdf"); } } }
Imports System.Diagnostics Imports BitMiracle.Docotic.Pdf Namespace BitMiracle.Docotic.Pdf.Samples Public NotInheritable Class CopyPages Public Shared Sub Main() ' NOTE: ' When used in trial mode, the library imposes some restrictions. ' Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx ' for more information. Dim pdf As New PdfDocument("Sample Data\jfif3.pdf") ' copy third and first pages to a new PDF document (page indexes are zero-based) Dim copy As PdfDocument = pdf.CopyPages(New Integer() {2, 0}) copy.Save("CopyPages.pdf") copy.Dispose() pdf.Dispose() Process.Start("CopyPages.pdf") End Sub End Class End Namespace
