XDoc.PDF
Features
Tech Specs
How-to C#
Pricing
How to Start Convert PDF Read PDF Build PDF Work with PDF Modules PDF Document PDF Pages Text Image Graph & Path Annotation, Markup & Drawing Redaction Security Digital Signature Forms Watermark Bookmark Link File Attachment File Metadata Printing Work with Other SDKs Barcode read Barcode create OCR Twain

C# PDF Page Parser Library
How to open, get, page count, add, copy, paste, cut PDF pages using C# .net


Easy to Use C# Code to Extract PDF Pages, Copy Pages from One PDF File and Paste into Others in C#.NET Program. Free Online Trial Download.










  • Free PDF document processing SDK supports PDF page extraction, copying and pasting in Visual Studio .NET project
  • Free .NET PDF manipulation library for quick integration in both Visual C# .NET WinForms and ASP.NET application
  • Online C# source code for extracting, copying and pasting PDF pages in C#.NET console class
  • Support .NET WinForms, ASP.NET MVC in IIS, ASP.NET Ajax, Azure cloud service, DNN (DotNetNuke), SharePoint
  • Able to extract PDF pages and save changes to original PDF file in C#.NET
  • Able to extract single or multiple pages from adobe PDF file and save into a new PDF file in .NET framework
  • Ability to copy selected PDF pages and paste into another PDF file


The portable document format, known as PDF document, is a widely-used form of file that allows users to open & read documents even though they are using different types of word processors. Besides, the capacity to be locked against editing or processing by others makes PDF file become increasingly popular among large enterprises and organizations.


With the purpose of helping C#.NET developers manipulate and edit PDF document file in a programming way, RasterEdge expressly designs this C#.NET PDF document imaging SDK, XDoc.PDF, which offers mature and easy to use APIs for programmers to handle & process PDF file at a page level. In this online article, we will address the robust functionality to copy and paste PDF page(s) in C#.NET document imaging application.






C# Clone a PDF Page


        #region clone one pdf page
        internal static void cloneOnePage()
        {
            String filepath = @"";
            String outPutFilePath = @"";
            PDFDocument doc = new PDFDocument(filepath);

            // Copy the first page of PDF document.
            PDFPage page = (PDFPage)doc.DuplicatePage(1);

            // Do further manipulations ...

        }
        #endregion




C# Copy and Paste PDF Pages


        #region Copy and Paste PDF Pages
        internal static void cloneAndPastePages()
        {
            // Copy three pages from test1.pdf and paste into test2.pdf.
            PDFDocument pdf = new PDFDocument(@"C:\test1.pdf");
            PDFDocument pdf2 = new PDFDocument(@"C:\test2.pdf");
            int[] pageindexes = new int[] { 1, 2, 4 };
            BasePage[] pages = pdf.DuplicatePages(pageindexes);
            pdf2.InsertPages(pages, 2);
        }
        #endregion




C# Copy and Replace PDF Pages


        #region Copy and Replace PDF Pages
        internal static void cloneAndReplacePages()
        {
            // Load the PDF file that provides the page object.
            String resFilePath = @"C:\2.pdf";
            PDFDocument resDoc = new PDFDocument(resFilePath);

            // Get the 1st page in the document.
            PDFPage page = (PDFPage)resDoc.GetPage(0);

            // Get PDFDocument object from a source file.
            String inputFilePath = @"C:\1.pdf";
            PDFDocument doc = new PDFDocument(inputFilePath);

            // Replace the 3rd page by the PDFPage object.
            int pageIndex = 2;
            doc.UpdatePage(page, pageIndex);

            // Save the PDFDocument.
            String outputFilePath = @"C:\Output.pdf";
            doc.Save(outputFilePath);
        }
        #endregion




C# Extract PDF Pages and Save into a New PDF File


        #region Extract PDF Pages and Save into a New PDF File
        internal static void extractPagesAndSaveToNewFile()
        {
            // Get PDFDocument object from a source file.
            String inputFilePath = @"C:\1.pdf";
            PDFDocument doc = new PDFDocument(inputFilePath);

            // Select pages.
            List<int> pageIndexes = new List<int>();
            pageIndexes.Add(2);   // The 3rd page.
            pageIndexes.Add(0);   // The 1st page.
            pageIndexes.Add(3);   // The 4th page.

            // Create the new document with 3 pages.
            PDFDocument newDoc = (PDFDocument)doc.GetMultiDocument(pageIndexes);

            // Save the PDFDocument.
            String outputFilePath = @"C:\Output.pdf";
            newDoc.Save(outputFilePath);
        }
        #endregion




C# Extract PDF Pages and Overwrite the Original PDF File


        #region Extract PDF Pages and Overwrite the Original PDF File
        internal static void extractPagesAndOverrideOriginalFile()
        {
            // Get PDFDocument object from a source file.
            String inputFilePath = @"C:\1.pdf";
            PDFDocument doc = new PDFDocument(inputFilePath);

            // Select pages.
            List<int> pageIndexes = new List<int>();
            pageIndexes.Add(2);   // The 3rd page.
            pageIndexes.Add(0);   // The 1st page.
            pageIndexes.Add(3);   // The 4th page.

            // Create the new document with 3 pages.
            PDFDocument newDoc = (PDFDocument)doc.GetMultiDocument(pageIndexes);

            // Save the PDFDocument.
            String outputFilePath = @"C:\1.pdf";
            newDoc.Save(outputFilePath);
        }
        #endregion