Page Organizer
If you use the full reader (UI Extensions), page organization is built into the thumbnail panel—users can reorder by drag, delete with long press, and more without extra code.
To implement page organization in code, use Core SDK (PDFDoc / PDFPage) or PDFViewCtrl to add, delete, move, import, extract, rotate, and flatten pages.
Page Operations via PDFDoc
Insert Pages
// Insert blank page with custom size (points; 1 inch = 72 points)
PDFPage page = doc.insertPage(0, 612.0f, 792.0f);
// Insert blank page with preset size
PDFPage page = doc.insertPage(0, PDFPage.e_SizeLetter);Note
Preset sizes include e_SizeLetter, e_SizeA3, e_SizeA4, and more. See the API Reference.
Delete Pages
// Delete by page index
doc.removePage(0);
// Delete by page object
doc.removePage(page);Move Pages
// Move page to target index
doc.movePageTo(page, 3);
// Move page range
Range range = new Range(0, 2);
doc.movePagesTo(range, 5);Import Pages
Import pages from another PDF file or PDFDoc:
// Import from file path
Range pageRange = new Range(0, 4);
Progressive progressive = doc.startImportPagesFromFilePath(
0, srcFilePath, null, 0, null, pageRange, null);
int state = Progressive.e_ToBeContinued;
while (state == Progressive.e_ToBeContinued) {
state = progressive.resume();
}
// Import from PDFDoc
Progressive progressive = doc.startImportPages(
0, srcDoc, 0, null, pageRange, null);Extract Pages
Extract pages to a new PDF file:
Range pageRange = new Range(0, 2);
Progressive progressive = doc.startExtractPages(
outputPath, 0, pageRange, null);
int state = Progressive.e_ToBeContinued;
while (state == Progressive.e_ToBeContinued) {
state = progressive.resume();
}Operations via PDFPage
Rotate Page
// Rotation: 0, 1, 2, 3 = 0°, 90°, 180°, 270°
page.setRotation(1);Set Page Size
// Custom size
page.setSize(612.0f, 792.0f);
// Preset size
page.setSize(PDFPage.e_SizeA4);Set Page Boxes
PDF pages define multiple boxes for display and clipping:
// Set crop box
RectF cropBox = new RectF(0, 0, 400, 600);
page.setBox(PDFPage.e_CropBox, cropBox);
// Get media box
RectF mediaBox = page.getBox(PDFPage.e_MediaBox);| Box Constant | Description |
|---|---|
e_MediaBox | Media box — full physical page size |
e_CropBox | Crop box — visible content area |
e_TrimBox | Trim box — final trimmed page size |
e_ArtBox | Art box — meaningful content boundary |
e_BleedBox | Bleed box — crop area including bleed |
Flatten Page
Flattening merges annotations and form fields into page content so they are no longer editable:
// Flatten entire page
page.flatten(true, 0);
// Flatten specific annotation
page.flattenAnnot(annot);Page Operations via PDFViewCtrl
PDFViewCtrl wraps UI-oriented page operations and refreshes the view automatically.
Insert Blank Pages
// Custom size
pdfViewCtrl.insertPages(0, 612.0f, 792.0f, 0, 0xFFFFFFFF, 0, 1);
// Preset size
pdfViewCtrl.insertPages(0, PDFPage.e_SizeLetter, 0, 0xFFFFFFFF, 0, 1);Import Pages from External File
int[] pageRanges = {0, 4};
pdfViewCtrl.insertPages(0, 0, null, srcFilePath, null, pageRanges);Delete Pages
int[] pageIndexes = {0, 2, 4};
pdfViewCtrl.removePages(pageIndexes);Move Pages
pdfViewCtrl.movePage(0, 3);Insert Image as Page
pdfViewCtrl.addImagePage(0, imagePath);API Reference
See the API Reference for full PDFDoc and PDFPage page organization APIs.