comet.CPage

class comet.CPage

This section describes all functions for the comet.CPage class.

CPage represents a document page

CPage represents a document artboard

Methods

CPage.getDocument()

Get the document this page belongs to.

Returns

The document

Return type

CDocument

Available

CPage.getUID()

Get the UID of this page as an int.

Returns

The UID of this page

Return type

int

Raises

CometError – On internal error

Available

CScript

page::get_uid

CPage.getIndex()

Get the 0-based index of this page.

Returns

The page index

Return type

int

Raises

CometError – On internal error

Available

CPage.setIndex(index)

Set the index of this page by moving the page to the desired index and moving everything behind the index back.

This will reshuffle the spreads

Attention: The resulting index may not be the one provided by the index parameter, e.g. when moving the page with index 0 to before index 1, the resulting index is still 0.

Parameters

index (int) –

The desired result index

  • 0: The page becomes the new first page

  • <0 or >= page count: The page becomes the new last page

  • Else: The target index

Return type

None

Raises
Available

CScript

page::move

CPage.getIndexInSpread()

Get the spread-relative index of this page.

Returns

The page index related to its spread

Return type

int

Raises

CometError – On internal error

Available

CScript

page::get_spread

CPage.getType()

Get the type of the page (left/right/unisex)

Returns

The page type.

One of Page types

Return type

int

Raises

CometError – On internal error

Available

CScript

page::get_type

CPage.getBounds()

Get the bounding box of this page.

Returns

The page bounds in global space.

Return type

CRect

Raises

CometError – On internal error

Available

CPage.getSize(marginRelative=False)

Get the size of this page.

Parameters

marginRelative (bool) –

Subtract the margins from the page size?

  • True: Without margins

  • False: Full page size

Returns

The page size as (width, height)

Return type

tuple[float, float]

Raises
Available

CScript

page::get_size

CPage.setSize(width, height, refPoint=0)

Set the size of this page.

Parameters
Return type

None

Raises
  • TypeError – When parameter types are invalid

  • ValueError

    • When parameters width or height have invalid value (< 1.0)

    • When parameter refPoint has invalid value

  • CometError – On internal error

Available

CScript

page::set_size

CPage.getPosition()

Get the position of this page.

Returns

The position in global space as [x, y]

Return type

tuple[float, float]

Raises

CometError – On internal error

Available

CPage.setPosition(x, y, refPoint=0)

Set the position of this page.

Parameters
Return type

None

Raises
Available

CPage.getMargins(facingRule=0)

Get the page margins. Right and bottom margins are based on right/bottom page size.

Parameters

facingRule (int) –

How to return values for facing pages.

  • 0: inner, top, outer, bottom

  • 1: left, top, right, bottom

Returns

The page margins as (insideLeft, top, outsideRight, bottom)

Return type

tuple[float, float, float, float]

Raises
Available

CScript

page::get_margins

CPage.setMargins(insideLeft, top, outsideRight, bottom, facingRule=0)

Set the margins of this page

Parameters
  • insideLeft (float) – New inside (for facing pages) or left margin

  • top (float) – New top margin

  • outsideRight (float) – New outside (for facing pages) or right margin

  • bottom (float) – New bottom margin

  • facingRule (int) –

    To what do the new values refer?

    • 0: inner, top, outer, bottom

    • 1: left, top, right, bottom

Return type

None

Raises
  • TypeError – When parameter types are invalid

  • ValueError

    • When parameter margin values are invalid (< 0.0)

    • When parameter facingRule has invalid value

  • CometError – On internal error

Available

CScript

page::set_margins

CPage.getColumnCount()

Get the column count of this page.

Returns

The column count

Return type

int

Raises

CometError – On internal error

Available

CScript

page::count_columns

CPage.getColumnGutter()

Get the column gutter of this page.

Returns

The column gutter

Return type

float

Raises

CometError – On internal error

Available

CScript

page::count_columns

CPage.getName(includeSectionName=True, useIntStyle=True, numberingType=0, abbreviate=True)

Get the name of this page.

Parameters
  • includeSectionName (bool) –

    Include the section name?

    Ignored

  • useIntStyle (bool) –

    • True: Use arabic numerals in string

    • False: Use the style of this section

    Ignored

  • numberingType (int) –

    Which page numbering settings are to be used?

    • 0: InDesign® settings

    • 1: Document settings

    • 2: Pages counted beginning from 1

    Ignored

  • abbreviate (bool) –

    Use abbreviation?

    Ignored

Return type

None

Raises
CScript

page::get_str_by_index

Available

CPage.getPageItems(recursive=False)

Get all pageitems on this page.

Parameters

recursive (bool) –

Whether to resolve hierarchies completely.

  • False Only return root pageitems.

  • True Flatten hierarchies, omitting groups from the result.

Returns

The pageitems of the page.

Return type

list[CPageItem]

Raises
Available

CScript
CPage.getFrames(subFrames=False, placeHolders=[], layers=[], cometGroups=[], names=[])

Get all frames on this page applying various optional filters.

Parameters
  • subFrames (bool) – Insert subframes into the result?

  • placeHolders (list[int]) –

    Restrict the result to frames with placeholder IDs in this list.

    • Empty list : Do not impose restrictions

    • [-1] : Restrict to all frames with placeholders

  • layers (list[str] | list[CLayer]) –

    Restrict the result to frames on the provided layers.

    The parameter type can be:

    When the parameter is list [CLayer], all layers must belong to the same document as this page.

  • cometGroups (list[int]) –

    Restrict the result to frames with the provided comet group IDs.

    • Empty list : Do not impose restrictions

  • names (list[str]) –

    Restrict the result to frames with the provided names.

    Entries may also contain regular expressions.

    • Empty list : Do not impose restrictions

Returns

A list of frames matching the provided criteria on this page

Return type

list[CFrame]

Raises
CScript
Available

CPage.getMasterPage()

Fetch the name of the master page of this page.

Returns

The full name of the master page

Return type

str

Raises

CometError – On internal error

Available

CScript

page::get_masterpage

CPage.setMasterPage(masterPage, resize=False)

Change the master mage of this page.

Parameters
  • masterPage (str) –

    Prefix and name of an existing master page.

    e.g. ‘A-Mustervorlage’

  • resize (bool) –

    Change page size according to the master page?

    • True: Yes, change page size if necessary

    • False: No, keep current page size

Return type

None

Raises
Available

CScript

page::set_masterpage

CPage.getInfo(attribute)

Retrieve information about a page template.

Parameters

attribute (int) –

The attribute to query.

One of Page info.

Returns

The value for the queried attribute.

The return type depends on the attribute.

Return type

None

Raises
Available

CScript

page::get_info

CPage.setInfo(attribute, value)

Set information about a page template.

Parameters
  • attribute (int) –

    The attribute to set.

    One of Page info.

  • value (int | str | bool) –

    The value to set.

    The type must match the attribute.

Return type

None

Raises
Available

CScript

page::get_info

CPage.createSnapshot(outPath, format='JPG', options={})

Create a preview snapshot of this page and save it as a file.

Parameters
  • outPath (str) – The absolute file path to save the snapshot to.

  • format (str) –

    Target format of the preview.

    The following values are valid:

    • ‘JPG’, ‘JPEG’

    • ‘PNG’

    • ‘GIF’, ‘GIFF’

    • ‘TIF’, ‘TIFF’

  • options (dict) –

    Export options.

    Keys in this dictionary are of type str.

    Depending on the chosen export format, for following options are available:

    All formats

    ’kResolution’

    The target resolution in DPI.

    • Type: float

    • Default: 144.0

    PNG

    ’kBackground’

    The background color setting to apply.

    • Value type: str

    • Default: ‘kTransparent’

    Allowed values:

    • ’kTransparent’

      Transparent background

    • ’kWhite’

      White background

    • ’Black’

      Black background

    JPG

    ’kQuality’

    • Value type: int

    • Default: 10

    JPG quality in range 0-10.

    only.

Return type

None

Raises
Available

CScript

image::snapshot_page

CPage.remove(reshuffle=True)

Deletes this page from it’s document.

All subsequent calls to this page’s functions will fail.

At least one page has to remain in the document, so if this is the last page this function will fail.

Parameters

reshuffle (bool) –

Should the following pages be rearranged?

Ignored, the value is always True

Ignored

Return type

None

Raises
Available

CScript

page::remove