Skip to content
Document Authoring DA  API Docs v1.10.0
npmGitHub

PageMargins

PageMargins:

Defines the margin dimensions for all four edges of a page.

PageMargins specifies the whitespace between the page edges and the content area for a section. All margin values are measured in points (1 point = 1/72 inch).

Page margins are configured through PageSetup.setPageMargins and retrieved via PageSetup.pageMargins. Each section can have its own margin settings, allowing different parts of a document to have different layouts.

Common margin values:

  • Normal margins (US Letter): 72 points (1 inch) on all sides
  • Narrow margins: 36 points (0.5 inch) on all sides
  • Wide margins: 144 points (2 inches) on all sides

Get current margins:

const pageSetup = section.pageSetup();
const margins = pageSetup.pageMargins();
console.log(`Top: ${margins.top}pt`);
console.log(`Bottom: ${margins.bottom}pt`);
console.log(`Left: ${margins.left}pt`);
console.log(`Right: ${margins.right}pt`);

Set standard 1-inch margins:

const pageSetup = section.pageSetup();
pageSetup.setPageMargins({
top: 72,
bottom: 72,
left: 72,
right: 72
});

Set narrow margins (0.5 inch):

pageSetup.setPageMargins({
top: 36,
bottom: 36,
left: 36,
right: 36
});

left: number

The left margin width in points.

Distance from the left edge of the page to the start of the content area. Measured in points (1 point = 1/72 inch).


right: number

The right margin width in points.

Distance from the right edge of the page to the end of the content area. Measured in points (1 point = 1/72 inch).


top: number

The top margin height in points.

Distance from the top edge of the page to the start of the content area. Measured in points (1 point = 1/72 inch).


bottom: number

The bottom margin height in points.

Distance from the bottom edge of the page to the end of the content area. Measured in points (1 point = 1/72 inch).