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
- Available
- CPage.getUID()¶
Get the UID of this page as an int.
- Returns
The UID of this page
- Return type
- Raises
CometError – On internal error
- Available
- CScript
- CPage.getIndex()¶
Get the 0-based index of this page.
- Returns
The page index
- Return type
- 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
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CPage.getIndexInSpread()¶
Get the spread-relative index of this page.
- Returns
The page index related to its spread
- Return type
- Raises
CometError – On internal error
- Available
- CScript
- CPage.getType()¶
Get the type of the page (left/right/unisex)
- Returns
The page type.
One of Page types
- Return type
- Raises
CometError – On internal error
- Available
- CScript
- CPage.getBounds()¶
Get the bounding box of this page.
- Returns
The page bounds in global space.
- Return type
- 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?
- Returns
The page size as (width, height)
- Return type
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- CPage.setSize(width, height, refPoint=0)¶
Set the size of this page.
- Parameters
width (float) – The new width
height (float) – The new height
refPoint (int) –
The reference point which is fixed during resize.
One of Reference Points.
Default is
comet.kRefPointTopLeft
.
- Return type
- Raises
TypeError – When parameter types are invalid
When parameters width or height have invalid value (< 1.0)
When parameter refPoint has invalid value
CometError – On internal error
- Available
- CScript
- CPage.getPosition()¶
Get the position of this page.
- Returns
The position in global space as [x, y]
- Return type
- Raises
CometError – On internal error
- Available
- CPage.setPosition(x, y, refPoint=0)¶
Set the position of this page.
- Parameters
x (float) – The new X position
y (float) – The new Y position
refPoint (int) –
The reference point which is moved to x/y.
One of Reference Points.
Default is
comet.kRefPointTopLeft
.
- Return type
- Raises
TypeError – When parameter types are invalid
ValueError – When parameter refPoint has invalid value
CometError – On internal error
- 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
- Raises
TypeError – When parameter types are invalid
ValueError – When parameter facingRule has invalid value
CometError – On internal error
- Available
- CScript
- 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
- Raises
TypeError – When parameter types are invalid
When parameter margin values are invalid (< 0.0)
When parameter facingRule has invalid value
CometError – On internal error
- Available
- CScript
- CPage.getColumnCount()¶
Get the column count of this page.
- Returns
The column count
- Return type
- Raises
CometError – On internal error
- Available
- CScript
- CPage.getColumnGutter()¶
Get the column gutter of this page.
- Returns
The column gutter
- Return type
- Raises
CometError – On internal error
- Available
- CScript
- CPage.getName(includeSectionName=True, useIntStyle=True, numberingType=0, abbreviate=True)¶
Get the name of this page.
- Parameters
- Return type
- Raises
TypeError – When parameter types are invalid
ValueError – When parameter numberingType has invalid value
CometError – On internal error
- CScript
- Available
- CPage.getPageItems(recursive=False)¶
Get all pageitems on this page.
- Parameters
recursive (bool) –
Whether to resolve hierarchies completely.
- Returns
The pageitems of the page.
- Return type
- Raises
TypeError – When parameter types are invalid.
CometError – On internal error
- 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?
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.Restrict the result to frames with the provided comet group IDs.
Empty list : Do not impose restrictions
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
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- CScript
- Available
- CPage.getMasterPage()¶
Fetch the name of the master page of this page.
- Returns
The full name of the master page
- Return type
- Raises
CometError – On internal error
- Available
- CScript
- CPage.setMasterPage(masterPage, resize=False)¶
Change the master mage of this page.
- Parameters
- Return type
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript
- 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
- Raises
TypeError – When parameter types are invalid
ValueError – When parameter attribute has invalid value
CometError – On internal error
- Available
- CScript
- CPage.setInfo(attribute, value)¶
Set information about a page template.
- Parameters
- Return type
- Raises
TypeError – When parameter types are invalid
ValueError – When parameter attribute has invalid value
CometError – On internal error
- Available
- CScript
- 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
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
- Return type
- Raises
TypeError – When parameter types are invalid
ValueError – When parameter outPath is empty
CometError – On internal error
- Available
- CScript
- 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
- Raises
TypeError – When parameter types are invalid
CometError – On internal error
- Available
- CScript