XDoc.PDF
Features
Tech Specs
How-to C#
How-to VB.NET
Pricing
Page: Insert PDF Pages
Work with Other SDKs
Page: Insert PDF Pages
  |  
Home ›› XDoc.PDF ›› C# PDF: Insert PDF Page

C#.NET PDF Library - Insert Blank PDF Page in C#.NET


Guide C# Users to Insert PDF Page from a Supported File Format in Visual C# .NET Class




Best C#.NET PDF SDK for inserting PDF pages in Visual Studio .NET framework


Free .NET evaluation library for adding pages to adobe PDF in both .NET WinForms application and ASPX webpage


Support .NET WinForms, ASP.NET MVC in IIS, ASP.NET Ajax, Azure cloud service, DNN (DotNetNuke), SharePoint


C#.NET source code for inserting a single one page or multiple pages to PDF document in .NET console application


Able to create a blank PDF page in both web server-side application


C#.NET users can insert a PDF page from a supported file format


Ability to add PDF page number in preview


Offer PDF page break inserting function


C#.NET PDF document editor library control, RasterEdge XDoc.PDF, offers easy & mature APIs for developers to add & insert an (empty) page into an existing PDF document file. Besides, this PDF document page inserting library control toolkit allows developers to specify where they want to insert (blank) PDF document page (before the first page or after the last page or after any desired page of current PDF document) using C# .NET class code.


This C# .NET PDF document page inserting & adding component from RasterEdge is written in managed C# code and designed particularly for .NET class applications. Thus, using this PDF document page manipulating and processing control SDK, you can create & add new PDF page(s) to current target PDF document in both web server-side application and Windows Forms project using a few lines of simple C# code.


Apart from the ability to inserting a new PDF page into existing PDF document file, RasterEdge C# .NET PDF document page processing and editing control toolkit also owns other advanced PDF document page manipulating functions. RasterEdge offers detailed guidances for each of those page processing functions, such as how to merge PDF document files by C# code, how to rotate PDF document page, how to delete PDF page using C# .NET, how to reorganize PDF document pages and how to split PDF document in C# .NET class application.


By using reliable APIs, C# programmers are capable of adding and inserting (empty) PDF page or pages from various file formats, such as PDF, Tiff, Word, Excel, PowerPoint, Bmp, Jpeg, Png, Gif, and so on. Some C# demos are provided for your reference.




DLLs for Inserting Page to PDF Document in .NET



Add necessary references:


  RasterEdge.Imaging.Basic.dll


  RasterEdge.Imaging.Basic.Codec.dll


  RasterEdge.Imaging.Drawing.dll


  RasterEdge.Imaging.Font.dll


  RasterEdge.Imaging.Processing.dll


  RasterEdge.XImage.Raster.dll


  RasterEdge.XImage.Raster.Core.dll


  RasterEdge.XDoc.PDF.dll


Use corresponding namespaces;


  using RasterEdge.Imaging.Basic;


  using RasterEdge.XDoc.PDF;


Note: When you get the error "Could not load file or assembly 'RasterEdge.Imaging.Basic' or any other assembly or one of its dependencies. An attempt to load a program with an incorrect format", please check your configure as follows:

       

       If you are using x64 libraries/dlls, Right click the project -> Properties -> Build -> Platform target: x64.

       

       If using x86, the platform target should be x86.




C#.NET Sample Code to Add and Insert a Page to PDF File



This C# demo will help you to insert a PDF page to a PDFDocument object at specified position.




String inputFilePath1 = Program.RootPath + "\\" + "1.pdf";
String inputFilePath2 = Program.RootPath + "\\" + "2.pdf";
String outPutFilePath = Program.RootPath + "\\" + "Output.pdf";

PDFDocument doc1 = new PDFDocument(inputFilePath1);
PDFDocument doc2 = new PDFDocument(inputFilePath2);

// Get a page from the first document.
PDFPage page = (PDFPage)doc1.GetPage(0);

// Specify a position for inserting the selected page.
int pageIndex = 2;

// Insert the page to the second document at specified position.
doc2.InsertPage(page, pageIndex);

// Output the new document.
doc2.Save(outPutFilePath);





C#.NET Sample Code to Add and Insert Multiple PDF Pages to PDF Document



Moreover, you may use the following C# demo code to insert multiple pages of a PDF file to a PDFDocument object at user-defined position.




String inputFilePath1 = Program.RootPath + "\\" + "1.pdf";
String inputFilePath2 = Program.RootPath + "\\" + "2.pdf";
String outPutFilePath = Program.RootPath + "\\" + "Output.pdf";

PDFDocument doc1 = new PDFDocument(inputFilePath1);
PDFDocument doc2 = new PDFDocument(inputFilePath2);

// Get page 0, page 1 and page 2 from the first document.
PDFPage page0 = (PDFPage)doc1.GetPage(0);
PDFPage page1 = (PDFPage)doc1.GetPage(1);
PDFPage page2 = (PDFPage)doc1.GetPage(2);
PDFPage[] pages = new PDFPage[3] { page0, page1, page2 };

// Specify a position for inserting the selected pages.
int pageIndex = 1;

// Insert the pages to the second document at specified position.
doc2.InsertPages(pages, pageIndex);

// Output the new document.
doc2.Save(outPutFilePath);





C# Sample Code to Add and Insert Blank Page to PDF File



This C# demo explains how to insert an empty page to a specific location of current PDF file.




String filepath = @"";
String outPutFilePath = @"";
PDFDocument doc = new PDFDocument(filepath);

// Insert an empty page at 2 (previous to the third page).
doc.AddEmptyPage(2);

// Save the file.
doc1.Save(outPutFilePath);





public override void AddPage(BasePage page)

Description:
     Add a PDF page into PDF file at default position, first page number.

Parameters:



public override void AddPage(BasePage[] pages)

Description:
     Add PDF pages into PDF file at default position, first page number.

Parameters:



public override void InsertPage(BasePage page, int pageIdx)

Description:
     Insert a PDF page into PDF file at specifiec position through page index.

Parameters:



public override void InsertPage(BasePage[] pages, int pageIdx)

Description:
     Insert PDF pages into PDF file at specifiec position through page index.

Parameters:



public int AddEmptyPage(int pageIndex)

Description:
     Add a blank page to PDF file at specified position.

Parameters:

Return:
     Error code, 0 if success.



public int AddEmptyPage(int pageIndex, PaperSize pageSize)

Description:
     Add a blank page with specified size to PDF file at specified position.

Parameters:

Return:
     Error code, 0 if success.



public int AddEmptyPages(int startPageIndex, int count)

Description:
     Add continuous blank pages to PDF file at specified position.

Parameters:

Return:
     Error code, 0 if success.



public int AddEmptyPages(int startPageIndex, int count, PaperSize pageSize)

Description:
     Add continuous blank pages to PDF file at specified position.

Parameters:

Return:
     Error code, 0 if success.



public void InsertPage(int pageIdx)

Description:
     Add a blank page to PDF file at specified position.

Parameters:



public void InsertPage(int pageIdx, PaperSize pageSize)

Description:
     Add a blank page with specified size to PDF file at specified position.

Parameters: