Accusoft.PdfXpress5.Net
Add, Insert & Delete Pages
See Also Send Feedback
PDF Xpress 5 for .NET - User Guide > How To > Modify PDF Document Content > Add, Insert & Delete Pages

Glossary Item Box

Create a Page in a PDF Document

The CreatePage method is called to add a new, empty page to a specified location within a PDF document.

The Adobe® PDF Library™ enforces the maximum allowable page size to 14,400 by 14,400 units (200 by 200 inches). PDF Xpress™ performs no special action in cases where an attempt is made to exceed this allowable page size.

C# Example Copy Code
// This code demonstrates how to create a new page in a PDF document
Accusoft.PdfXpressSdk.PdfXpress pdfXpress1  = null;
Document document = null;
PageOptions opts = null; 
try
{
      Accusoft.PdfXpressSdk.PdfXpress pdfXpress1  = new PdfXpress();
      pdfXpress1.Initialize();
      document = new Document(pdfXpress1, "test.pdf");
      opts = new PageOptions();
      opts.MediaHeight = 792;
      opts.MediaWidth = 612;
      const int pageNumber = 4;
      document.CreatePage(pageNumber, opts);
}
catch (System.Exception ex)
{          
}
finally
{
      if ( null != opts ) opts.Dispose( );
      if ( null != document ) document.Dispose( );
      if ( null != pdfXpress1 ) pdfXpress1.Dispose( );
}

 

Insert a Page into a PDF Document

Call the InsertPages method to insert one or more pages at a specified location within the PDF document.

C# Example Copy Code
// This code demonstrates how to insert a page into a PDF document
Accusoft.PdfXpressSdk.PdfXpress pdfXpress1   = null;
Document document = null;
Document  sourcedoc = null;
InsertPagesOptions io = null; 
try
{
      pdfXpress1  = new PdfXpress();
      pdfXpress1.Initialize();
      document = new Document (pdfXpress1, "C:\\pdfexample.pdf");
      sourcedoc = new Document(pdfXpress1, "C:\\test.pdf");
      io = new InsertPagesOptions();
      io.InsertAtPageNumber = 3;
      io.SourceDocument = sourcedoc;
      PageList pageList = new PageList();
      PageRange pageRange = new PageRange(0, 2);
      pageList.Add(pageRange);
      io.PageList = pageList;
      document.InsertPages(io);
}
catch (System.Exception ex)
{
}
finally
{
      if ( null != io) io.Dispose( );
      if ( null != sourcedoc) sourcedoc.Dispose( );
      if ( null != document ) document.Dispose( );
      if ( null != pdfXpress1 ) pdfXpress1.Dispose( );
}

Delete a Page from a PDF Document

Call the DeletePage method to delete a specified page from the PDF document.

C# Example Copy Code
// This code demonstrates how to delete a page in the PDF document
Accusoft.PdfXpressSdk.PdfXpress  pdfXpress1 = null;
Accusoft.PdfXpressSdk.Document document = null; 
try
{
      pdfXpress1 = new PdfXpress();              
      pdfXpress1.Initialize(null,null);
      document = new Document (pdfXpress1, "C:\\pdfexample.pdf");
      document.DeletePage(2);
}
catch (System.Exception ex)
{
}
finally
{
            if ( null != document ) document.Dispose( );
            if ( null != pdfXpress1 ) pdfXpress1.Dispose( );
}

 

See Also

©2012. Accusoft Corporation. All Rights Reserved.