Edit in GitHubLog an issue

Manage Pages

Learn how to programmatically create, access, and manage pages in Adobe Express documents using the Document API.

Understanding Pages in Adobe Express

In Adobe Express, documents are organized as a scenegraph - a hierarchical tree structure:

  • Document (root - ExpressRootNode)
    • Pages (PageNode in PageList)
      • Artboards (ArtboardNode in ArtboardList - timeline scenes)
        • Content (shapes, text, images, groups, etc.)

Every page contains at least one artboard. When a page has multiple artboards, they represent keyframe "scenes" in a linear animation timeline. All artboards within a page share the same dimensions.

Add a Page

Use the editor.documentRoot.pages.addPage() method to create a new page with specified dimensions.

Example: Add a Standard Page

Copied to your clipboard
// sandbox/code.js
import { editor } from "express-document-sdk";
// Define page dimensions (width x height in pixels)
const pageGeometry = {
width: 1080,
height: 1080
};
// Add a new page with the specified dimensions
const newPage = editor.documentRoot.pages.addPage(pageGeometry);
console.log("New page created:", newPage);
console.log("Page dimensions:", newPage.width, "x", newPage.height);

Example: Add Pages with Different Dimensions

Copied to your clipboard
// sandbox/code.js
import { editor } from "express-document-sdk";
// Add an Instagram post page (square)
const instagramPage = editor.documentRoot.pages.addPage({
width: 1080,
height: 1080
});
// Add a story page (vertical)
const storyPage = editor.documentRoot.pages.addPage({
width: 1080,
height: 1920
});
// Add a landscape page
const landscapePage = editor.documentRoot.pages.addPage({
width: 1920,
height: 1080
});
console.log("Created 3 pages with different dimensions");

Access Pages

Get the Current Page

Copied to your clipboard
// sandbox/code.js
import { editor } from "express-document-sdk";
// Get the currently active page
const currentPage = editor.context.currentPage;
console.log("Current page dimensions:", currentPage.width, "x", currentPage.height);
console.log("Number of artboards:", currentPage.artboards.length);

Access All Pages

Copied to your clipboard
// sandbox/code.js
import { editor } from "express-document-sdk";
// Get all pages in the document
const allPages = editor.documentRoot.pages;
console.log("Total pages in document:", allPages.length);
// Iterate through all pages
for (const page of allPages) {
console.log(`Page dimensions: ${page.width} x ${page.height}`);
console.log(`Artboards in this page: ${page.artboards.length}`);
}
// Access specific pages by index
const firstPage = allPages[0];
const lastPage = allPages[allPages.length - 1];

Working with Page Content

Add Content to a Specific Page

Copied to your clipboard
// sandbox/code.js
import { editor } from "express-document-sdk";
// Create a new page
const newPage = editor.documentRoot.pages.addPage({
width: 1080,
height: 1080
});
// The new page is automatically active, so content will be added to it
const textNode = editor.createText("Content on the new page!");
textNode.translation = { x: 100, y: 100 };
// Add to the current insertion parent (the new page's artboard)
editor.context.insertionParent.children.append(textNode);
console.log("Added text to the new page");

Work with Page Artboards

Copied to your clipboard
// sandbox/code.js
import { editor } from "express-document-sdk";
// Get the current page
const currentPage = editor.context.currentPage;
// Access the page's artboards
const artboards = currentPage.artboards;
console.log("Number of artboards:", artboards.length);
// Get the first (and typically only) artboard
const firstArtboard = artboards.first;
console.log("First artboard dimensions:", firstArtboard.width, "x", firstArtboard.height);
// Add content directly to a specific artboard
const rect = editor.createRectangle();
rect.width = 200;
rect.height = 200;
rect.translation = { x: 50, y: 50 };
firstArtboard.children.append(rect);

Common Patterns and Best Practices

Page Creation Workflow

Copied to your clipboard
// sandbox/code.js
import { editor } from "express-document-sdk";
function createTemplatePages() {
// Define common page sizes
const pageSizes = {
instagram: { width: 1080, height: 1080 },
story: { width: 1080, height: 1920 },
landscape: { width: 1920, height: 1080 },
a4: { width: 595, height: 842 }
};
// Create pages for each template
const pages = {};
for (const [name, dimensions] of Object.entries(pageSizes)) {
const page = editor.documentRoot.pages.addPage(dimensions);
pages[name] = page;
// Add a title to each page
const title = editor.createText(`${name.toUpperCase()} Template`);
title.translation = { x: 50, y: 50 };
editor.context.insertionParent.children.append(title);
console.log(`Created ${name} page: ${dimensions.width}x${dimensions.height}`);
}
return pages;
}
// Create template pages
const templatePages = createTemplatePages();

Check Page Properties

For detailed page information including content analysis and print readiness, see the Page Metadata How-to Guide.

Copied to your clipboard
// sandbox/code.js
import { editor } from "express-document-sdk";
function analyzeDocument() {
const pages = editor.documentRoot.pages;
console.log("=== Document Analysis ===");
console.log(`Total pages: ${pages.length}`);
for (let i = 0; i < pages.length; i++) {
const page = pages[i];
console.log(`\nPage ${i + 1}:`);
console.log(` Dimensions: ${page.width} x ${page.height}`);
console.log(` Artboards: ${page.artboards.length}`);
// Count content in each artboard
for (let j = 0; j < page.artboards.length; j++) {
const artboard = page.artboards[j];
console.log(` Artboard ${j + 1}: ${artboard.children.length} items`);
}
}
}
// Analyze the current document
analyzeDocument();

Key Concepts & Best Practices

Important: Use the Correct Method

Important Behaviors

  1. Automatic activation - Adding a page automatically makes it the active page and switches the viewport to it
  2. Required dimensions - The addPage() method requires a geometry parameter with width and height
  3. Default artboard - Every new page automatically gets one default artboard
  4. Shared dimensions - All artboards within a page must have the same dimensions
  5. Insertion context - editor.context.insertionParent points to the active artboard where new content is added

Integration with Other APIs

Pages created with editor.documentRoot.pages.addPage() integrate seamlessly with other Adobe Express APIs:

  • Metadata APIs - Use newPage.id with Add-on UI SDK metadata APIs to retrieve detailed page information. See the Page Metadata How-to Guide for complete examples.
  • Rendition APIs - Export specific pages as images, PDFs, or videos. See Create Renditions.
  • Selection APIs - Work with selected content on pages. See Handle Element Selection.
  • Content APIs - Add text, shapes, images, and other content to page artboards using the Document API.

FAQs

Q: How do I add a page programmatically?

A: Use editor.documentRoot.pages.addPage(dimensions) with page dimensions. There is no createPage() method.

Q: Why doesn't createPage() work?

A: The Document API uses editor.documentRoot.pages.addPage() for pages, not createPage(). Use editor.documentRoot.pages.addPage(dimensions) instead.

Q: How do I get the current page?

A: Use editor.context.currentPage to access the currently active page.

Q: How do I navigate between pages?

A: Adding a page automatically switches to it. You can also access pages via editor.documentRoot.pages.

Q: What happens when I add a page?

A: A new page with a default artboard is created and automatically becomes the active page. The artboard becomes the insertion parent for new content.

Q: Can I remove pages?

A: Currently, the Document API doesn't provide a direct method to remove pages programmatically.

Q: How do I access all pages in a document?

A: Use editor.documentRoot.pages to access the PageList containing all pages.

Q: What are the minimum requirements for a page?

A: Every page must have at least one artboard. The editor.documentRoot.pages.addPage() method automatically creates a default artboard.

Page Information and Metadata

  • Page Metadata - Get detailed information about pages, including dimensions, content types, and selected page IDs
  • Document Metadata - Access document-level information and listen for document events
  • getSelectedPageIds() API - Retrieve IDs of currently selected pages (experimental)

Working with Page Content

Document Structure and Context

Advanced Topics

  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2025 Adobe. All rights reserved.