Android
ComPDFKit PDF SDK
Guides

Page Edit

 

Page manipulation is the ability to perform changes to pages.

- To delete pages from a PDF document, use function CPDFDocument.removePages(int[] pageIndexs).

- To insert a blank page into a PDF document, use function CPDFDocument.insertBlankPage(int pageIndex, float width, float height).

- To insert an image as an entire page into a PDF document, use function CPDFDocument.insertPageWithImagePath(int pageIndex, float width, float height, String imagePath).

- To insert specific page from one document to another, use function CPDFDocument.importPages(CPDFDocument otherDocument, int start, int end, int insertPosition).

- To move a page to a new location, use function CPDFDocument.movePage(int fromIndex, int toIndex).

- To exchange the location of two document pages, use function CPDFDocument.exchangePage(int firstIndex, int secondIndex).

- To replace original document pages with new pages from a different document, use function CPDFDocument.removePages(int[] pageIndexs) and CPDFDocument.importPages(CPDFDocument otherDocument, int start, int end, int insertPosition).

- To rotate a page in a PDF document, refer to the following method in the CPDFPage class.

 

// Rotation on a page. Must be 0, 90, 180 or 270 (negative rotations will be "normalized" to one of 0, 90, 180 or 270).
// Some PDF's have an inherent rotation and so -[rotation] may be non-zero when a PDF is first opened.
CPDFPage pdfPage = pdfDocument.pageAtIndex(pageIndex);
int rotation = pdfPage.getRotation();
pdfPage.setRotation(rotation + 90);