---
title: "Sections and page setup"
canonical_url: "https://www.nutrient.io/guides/document-authoring/page-layout/sections-and-page-setup/"
md_url: "https://www.nutrient.io/guides/document-authoring/page-layout/sections-and-page-setup.md"
last_updated: "2026-07-09T00:00:00.000Z"
description: "Control page size, orientation, and margins in Document Authoring through a section’s page setup."
---

# Set up sections and pages

A document contains sections. Each section controls its own page size, orientation, and margins through [`Section.pageSetup()`](https://www.nutrient.io/api/document-authoring/types/programmatic/section/#pagesetup). A new document starts with one section, and documents can include more sections through section breaks. Read and update section setup inside a [transaction](https://www.nutrient.io/guides/document-authoring/editing-content/programmatic-editing.md).

As of [1.17.0](https://www.nutrient.io/guides/document-authoring/changelog.md#1.17.0), page margins also include `header` and `footer` distances, so you can control how far headers and footers sit from the page edge for each section.

Document Authoring stores page dimensions in points. One point is 1/72 inch, so one inch is 72 points. For example, US Letter, which is 8.5 × 11 inches, is 612 × 792 points. A standard one-inch margin uses a value of 72.

Before you start, make sure the Document Authoring library is installed and running in your app. If you haven’t set it up yet, refer to the [getting started](https://www.nutrient.io/sdk/document-authoring/getting-started.md) guide.

The examples omit error handling. Add it before you use this code in production.

## Read the current page setup

Use [`pageSize()`](https://www.nutrient.io/api/document-authoring/types/programmatic/pagesetup/#pagesize) and [`pageMargins()`](https://www.nutrient.io/api/document-authoring/types/programmatic/pagesetup/#pagemargins) to read the current dimensions for a section:

```js

const currentDoc = editor.currentDocument();

await currentDoc.transaction(async ({ draft }) => {
  const [section] = draft.body().sections();
  const pageSetup = section.pageSetup();

  const size = pageSetup.pageSize();
  const margins = pageSetup.pageMargins();

  console.log(`Page: ${size.width} x ${size.height} pt`);
  console.log(`Margins: ${margins.top}/${margins.right}/${margins.bottom}/${margins.left} pt`);
  console.log(`Header/footer: ${margins.header}/${margins.footer} pt`);

  return false;
});

```

The examples below assume `currentDoc` is defined as `editor.currentDocument()`.

## Set the page size

Pass the width and height in points. US Letter is `612 x 792`, and A4 is `595 x 842`:

```js

await currentDoc.transaction(async ({ draft }) => {
  const [section] = draft.body().sections();

  section.pageSetup().setPageSize({ width: 595, height: 842 }); // A4

  return true;
});

```

## Switch orientation

Document Authoring doesn’t use an orientation flag. Swap the width and height to rotate the page:

```js

await currentDoc.transaction(async ({ draft }) => {
  const pageSetup = draft.body().sections()[0].pageSetup();
  const { width, height } = pageSetup.pageSize();

  pageSetup.setPageSize({ width: height, height: width });

  return true;
});

```

## Set the margins

Use [`setPageMargins()`](https://www.nutrient.io/api/document-authoring/types/programmatic/pagesetup/#setpagemargins) to set any of the four page edges. A value of 72 equals 1 inch:

```js

await currentDoc.transaction(async ({ draft }) => {
  draft.body().sections()[0].pageSetup().setPageMargins({
    top: 72,
    right: 72,
    bottom: 72,
    left: 72,
  });

  return true;
});

```

## Set header and footer distances

Use the `header` and `footer` fields on [`PageMargins`](https://www.nutrient.io/api/document-authoring/types/programmatic/pagesetup/#pagemargins) to control how far headers and footers are placed from the page edge. Omitted margin fields keep their current values.

```js

await currentDoc.transaction(async ({ draft }) => {
  draft.body().sections()[0].pageSetup().setPageMargins({
    header: 36,
    footer: 36,
  });

  return true;
});

```

## Configure every section

When a document has more than one section, [`sections()`](https://www.nutrient.io/api/document-authoring/types/programmatic/body/#sections) returns them in order. Configure each section independently. This example applies narrow margins and matching header/footer distances across the whole document.

```js

await currentDoc.transaction(async ({ draft }) => {
  for (const section of draft.body().sections()) {
    section.pageSetup().setPageMargins({
      top: 36,
      right: 36,
      bottom: 36,
      left: 36,
      header: 36,
      footer: 36,
    });
  }

  return true;
});

```

## Learn more

**[Headers and footers](https://www.nutrient.io/guides/document-authoring/page-layout/headers-and-footers.md)**\
Edit header and footer content for each section.

**[Programmatic editing](https://www.nutrient.io/guides/document-authoring/editing-content/programmatic-editing.md)**\
Learn how transactions work and how to use the document model.
---

## Related pages

- [Work with headers and footers](/guides/document-authoring/page-layout/headers-and-footers.md)

