Accusoft.PdfXpress7.Net
Add, Insert & Delete Pages

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.

PDF Xpress™ 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
            {
                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)
            {
            }
            finally
            {
                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)
            {
            }
            finally
            {
                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)
            {
            }
            finally
            {
                if (null != document)
                {
                    document.Dispose();
                }
                if (null != pdfXpress1)
                {
                    pdfXpress1.Dispose();
                }
            }
See Also

 

 


©2018. Accusoft Corporation. All Rights Reserved.

Send Feedback