Guide for C#
Core Document Formats
Add, Insert, Delete or Sort Order of PDF Page
Additional Features

C# PDF - Modify PDF Page Using C#

How to Add, Delete & Sort PDF Page(s) Using C#.NET Code

Visual C#
Home > .NET Imaging SDK > C# > Modify Document Page
If this is your first time to use our DocImageSDK, we strongly suggest you reading How to Start first!

C#.NET PDF Page Modifier Control Overview
RasterEdge C#.NET PDF document editor SDK, following .NET class library design guidance, offers a robust feature set to support all your PDF document level processing needs. In this article, we will mainly talk about its page modifying functions. Following is a feature list of C#.NET PDF page modifier control.
  • Powerful .NET SDK that can be integrated into ASP.NET web applications, Windows programs and Console applications
  • Easily manipulate multi-page PDF document file with page inserting, deleting and re-ordering functions
  • Process PDF document pages using C#.NET code, without depending on any product from Adobe
  • Compatible with Microsoft Visual Studio 2005, VS 2008, VS 2010 and VS 2012
This C#.NET online tutorial page aims to tell developers how to modify PDF pages in C#.NET imaging application. Here is the article layout of this C#.NET PDF page manipulating tutorial page.
  • Brief introduction to classes involved in the process of C# PDF document page manipulation
  • APIs and C#.NET demo code to insert a page into source PDF document file
  • APIs and C#.NET sample code to delete certain page from target PDF file
  • APIs and C#.NET programming example to change the order of source PDF file
C#.NET Programming Classes Introduction
In the process of document page modification and manipulation using C#.NET PDF page modifier control, there are two programming classes that will be used. One is PDFPage and the other is PDFDocument. And in this section, in order to eliminate the possible confusions in understanding following PDF page processing APIs, we here briefly introduce these two programming classes.
  • PDFDocument: Derived from super class REDocument, it is a high-level programming model of PDF document file. This class contains all PDF document information, such as pages in the PDF file.
  • PDFPage: Derived from super class REPage, it is an abstraction of PDF document page contained in PDFDocument.
How to Insert PDF Page Using C#
If you want add an empty page to source PDF document file in C#.NET program, you should call the AddPage method which allows you to decide where the blank page will be inserted on source PDF file. For example, if you input the page index as 2, then, the created empty PDF page will be inserted into source PDF file as the third page.
What should be noted here is that, apart from inserting an empty page into target PDF file, this C#.NET PDF page modifier control also enables developer to add certain page that he gets from other PDFDocument.

C#.NET PDF Processing APIs to Add PDF Page

PDFDocument PDFDocument.AddPage(BasePage page);
PDFDocument PDFDocument.InsertPage(BasePage page, int pageIdx);

C#.NET Demo Code for PDF Page Insertion

/// <summary>
/// create an empty page and insert it into an exsisting PDFDocument
/// </summary>
/// <param name="doc"></param>
/// <param name="idx"></param>
public void CreateAndInsertEmptyPage(PDFDocument doc, int idx)
BasePage page = PDFDocument.CreateEmptyPage();
doc.InsertPage(page, idx);
How to Remove PDF Page Using C#
If you want to delete or remove a page from PDFDocument in C# project, you can call DeletePage method and provide the input as the page index that you need to remove from source PDF file. For example, if you want to delete the second page from source multi-page PDF file, you just need to input the page index as 1 using DeletePage method.

C#.NET PDF Processing APIs to Delete PDF Page

PDFDocument PDFDocument.DeletePage(int pageIdx);

C#.NET Demo Code for PDF Page Deletion

public void DeletePage(String filePath, int pageIndx)
PDFDocument doc = new PDFDocument(filePath);
How to Reorganize PDF Pages Using C#
If you want to change the page order of source PDF document file, you should call SortPage method and provide the input as new PDF page order.

C#.NET PDF Processing APIs to Reorder PDF Pages

PDFDocument PDFDocument.SortPage(List<int> pageOrder);

C#.NET Demo Code for Sorting PDF Page Order

public void SortPageOrder(String filePath, List<int> pageOrder)
PDFDocument doc = new PDFDocument(filePath);
If you want to see more C#.NET online tutorials on PDF document processing at page level, like C#.NET sample code to add image to PDF page, C#.NET guidance on PDF document merger or splitter control and C#.NET demo code for PDF page extraction from source multi-page document file, please follow the links directly.

Recommend this to Google+