comet.CPage¶
- class comet.CPage¶
This section describes all functions for the comet.CPage class.
InDesign® comet_pdf® CPage represents a document page
Illustrator® CPage represents a document artboard
Methods¶
- CPage.getDocument()¶
Get the document this page belongs to.
- Returns:
The document
- Return type:
- Available:
InDesign® comet_pdf® Illustrator®
- CPage.getSpread()¶
Get the spread this page belongs to.
- Returns:
The containing spread.
- Return type:
- Available:
InDesign® comet_pdf®
- 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:
InDesign® comet_pdf®
- CScript:
- 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:
InDesign® comet_pdf®
- CScript:
- CPage.getIndex()¶
Get the 0-based index of this page.
- Returns:
The page index
- Return type:
- Raises:
CometError – On internal error
- Available:
InDesign® comet_pdf® Illustrator®
- 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:
TypeError – When parameter types are invalid
CometError – On internal error
- Available:
InDesign® comet_pdf®
- 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:
InDesign® comet_pdf®
- 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:
Illustrator®
- 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:
InDesign® comet_pdf® Illustrator®
- CScript:
- CPage.setSize(width, height, refPoint=0)¶
Set the size of this page.
InDesign® comet_pdf®
In page-based layouts such as those generated by InDesign® and comet_pdf, the size of the pages is a fundamental information and changing page sizes will lead to significant differences in the output.
This function only changes the page size! Apart from a possible re-adjustment of the frames according to the given reference point no reorganization of the page contents will be made! This means in particular:
Frame assignments to spreads (InDesign®) or pages (comet_pdf) remain unchanged. If frames fall geometrically from the spread or the page, they become invisible in the exported PDF.
There is no customization of the parent pages and their elements!
Any page templates remain unchanged.
InDesign® partially realizes changes to the page size by shifting the page coordinate system of the page. This can also change the frame coordinates.
- 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
constants.kRefPointTopLeft
.
- Return type:
None
- 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:
InDesign® comet_pdf® Illustrator®
- 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:
Illustrator®
- 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
constants.kRefPointTopLeft
.
- Return type:
None
- Raises:
TypeError – When parameter types are invalid
ValueError – When parameter refPoint has invalid value
CometError – On internal error
- Available:
Illustrator®
- 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:
InDesign® comet_pdf®
- 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:
None
- 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:
InDesign® comet_pdf®
- CScript:
- CPage.getColumnCount()¶
Get the column count of this page.
- Returns:
The column count
- Return type:
- Raises:
CometError – On internal error
- Available:
InDesign® comet_pdf®
- CScript:
- CPage.getColumnGutter()¶
Get the column gutter of this page.
- Returns:
The column gutter
- Return type:
- Raises:
CometError – On internal error
- Available:
InDesign® comet_pdf®
- CScript:
- CPage.getName(includeSectionName=True, useIntStyle=True, numberingType=0, abbreviate=True)¶
Get the name of this page.
- Parameters:
includeSectionName (bool) –
Include the section name?
Illustrator® Ignored
useIntStyle (bool) –
Illustrator® Ignored
numberingType (int) –
Which page numbering settings are to be used?
0: InDesign® settings
1: Document settings
2: Pages counted beginning from 1
Illustrator® Ignored
abbreviate (bool) –
Use abbreviation?
Illustrator® Ignored
- Return type:
None
- Raises:
TypeError – When parameter types are invalid
ValueError – When parameter numberingType has invalid value
CometError – On internal error
- CScript:
- Available:
InDesign® comet_pdf® Illustrator®
- 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:
InDesign® comet_pdf® Illustrator®
- 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:
InDesign® comet_pdf® Illustrator®
- 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:
InDesign® comet_pdf®
- CScript:
- CPage.setMasterPage(masterPage, resize=False)¶
Change the master mage of this page.
- Parameters:
- Return type:
None
- Raises:
TypeError – When parameter types are invalid
CometError – On internal error
- Available:
InDesign® comet_pdf®
- CScript:
- CPage.loadMasterItems()¶
Load the placeholders for the frames from the master page of a page.
The frames taken from the respective master page of a document page are not automatically processed when editing the placeholders.
In order for master page elements to be treated as independent page content, they must first be localized. This localization can be done manually in the document. When changing the associated (non-localized) frame of the master page, only the frame properties from the master page that have not been overwritten are transferred.
Once frames have been localized, they can be edited and changed like normal frames. To localize a master page frame with
loadMasterItems()
, the frame must be linked to a placeholder with an ID > 0. An additional link to a product is not necessary, so the frame may have the record ID [0, 0, 0, ‘’].Repeated calls of
loadMasterItems()
are permitted.The function automatically recognizes whether a master page frame has already been localized. In this case, the placeholders of the localization are processed without localizing the frame again.
- Returns:
The newly localized frames.
- Return type:
- Raises:
CometError – On internal error
- Available:
InDesign® comet_pdf®
- 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:
None
- Raises:
TypeError – When parameter types are invalid
ValueError – When parameter attribute has invalid value
CometError – On internal error
- Available:
InDesign® comet_pdf®
- CScript:
- CPage.setInfo(attribute, value)¶
Set information about a page template.
- Parameters:
- Return type:
None
- Raises:
TypeError – When parameter types are invalid
ValueError – When parameter attribute has invalid value
CometError – On internal error
- Available:
InDesign® comet_pdf®
- 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:
InDesign® Illustrator® ‘JPG’, ‘JPEG’
Illustrator® ‘PNG’
InDesign® ‘GIF’, ‘GIFF’
InDesign® ‘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:
None
- Raises:
TypeError – When parameter types are invalid
ValueError – When parameter outPath is empty
CometError – On internal error
- Available:
InDesign® Illustrator®
- 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?
comet_pdf® Ignored, the value is always True
Illustrator® Ignored
- Return type:
None
- Raises:
TypeError – When parameter types are invalid
CometError – On internal error
- Available:
InDesign® comet_pdf® Illustrator®
- CScript: