Scripter2 API: Difference between revisions

From Scribus Wiki
Jump to navigation Jump to search
(link to https://scribus-scripter.readthedocs.org/en/latest/)
 
(21 intermediate revisions by one other user not shown)
Line 1: Line 1:
[[Category:Scribus]]
Scripter2 API is described below. This is a reference for the actual documentation of new scripter.  
==Document API==
Document object is created/used when there is an active document in Scribus. It provides the following objects, accessible as '''Scripter.activeDocument.'''
====layers====
Layers in the active document are accessible by creating a python object. This can be done by the statement : '''Scripter.activeDocument.layers'''
====colors====
Colors in the active document are accessible by creating a python object. This can be done by the statement : '''Scripter.activeDocument.colors'''
====objects====
Objects of the active document are accessible by creating a python object. This can be done by the statement : '''Scripter.activeDocument.objects'''


==Layer API==
See also rather : https://scribus-scripter.readthedocs.org/en/latest/


A layer object can be created by as '''Scripter.activeDocument.layers'''. All the functions mentioned below are used for manipulation of layers using python scripts.
The new Scripter is composed of different modules, which are either accessible externally, or via methods of other apis.


Sample script:
==Scripter==
    layerObject = Scripter.activeDocument.layers
===<u>Properties</u>===
    print layerObject.getLayers() #this will print the list of layers in active document.
====activeDocument====


QList<QVariant> '''getLayers'''()
:This property return '''DocumentAPI''' object.


void '''setActiveLayer'''(QString layer)
:Usage:


QString '''getActiveLayer'''()
::''document = Scripter.activeDocument''


void '''sendToLayer'''(QString layer, QString name)
::Here '''document''' will represent the active document, and is of type '''DocumentAPI'''


void '''setLayerVisible'''(QString layer, bool visible)
====activeWindow====
:This property return '''WindowAPI''' object.


void '''setLayerPrintable'''(QString layer, bool printable)
:Usage:
::''window = Scripter.activeWindow''


void '''setLayerLocked'''(QString layer, bool locked)
:: Here, '''window''' will represent the active window, and is of type '''WindowAPI'''. See WindowAPI for methods and properties available for this object.
====colors====
:This property will return a '''list''' of default colors in Scribus, each color as an object of '''ScColorWrapper'''.


void '''setLayerOutlined'''(QString layer, bool outline)
:Usage:
::''colors = Scripter.colors''
::''for i in colors:''
:::''print i.name''
:Result:
:::''Black''
:::''Blue''
:::''Cool Black''
:::''Cyan''
:::''Green''
:::''Magenta''
:::''Red''
:::''Registration''
:::''Rich Black''
:::''Warm Black''
:::''White''
:::''Yellow''
===Methods===
====openDocument====
====newDocument====


void '''setLayerFlow'''(QString layer, bool flow)
==Document API==
 
===Properties===
void '''setLayerBlendmode'''(QString layer, int blend)
====name====
 
====available====
void '''setLayerTransparency'''(QString layer, int trans)
====margins====
 
====modified====
bool '''isLayerVisible'''(QString layer)
====activePage====
 
====pageCount====
bool '''isLayerPrintable'''(QString layer)
====activeItem====
 
====dimensions====
bool '''isLayerLocked'''(QString layer)
====items====
 
====selection====
bool '''isLayerOutlined'''(QString layer)
====selectionCount====
 
====colors====
bool '''isLayerFlow'''(QString layer)
====layers====
 
====masterPages====
int '''getLayerBlendmode'''(QString layer)
====styles====
 
double '''getLayerTransparency'''(QString layer)
 
void '''deleteLayer'''(QString layer)
 
void '''createLayer'''(QString name)
 
==Object API==
QString '''createRect'''(double x, double y, double width, double height, QString name);
 
QString '''createEllipse'''(double x, double y, double width, double height, QString name);
 
QString '''createImage'''(double x, double y, double width, double height, QString name);
 
QString '''createText'''(double x, double y, double width, double height, QString name);
 
QString '''createTable'''(double x, double y, double width, double height, int numRows, int numColumns, QString name);
 
QString '''createLine'''(double x1, double y1, double x2, double y2, QString name);
 
QString '''createPolyLine'''(QList<QVariant> list, QString name);
 
QString '''createPolygon'''(QList<QVariant> list, QString name);
 
QString '''createBezierLine'''(QList<QVariant> list, QString name);
 
QString '''createPathText'''(double x, double y, QString textbox, QString beziercurve, QString name);
 
void '''deleteObject'''(QString name);
 
void '''textFlowMode'''(QString name, int stat);
 
bool '''objectExists'''(QString name);
 
void '''setStyle'''(QString style, QString name);
 
QList<QVariant> '''getAllStyles'''();
 
void '''duplicateObject'''(QString name);
 
void '''moveObject'''(double dx, double dy, QString name);
 
void '''moveObjectAbs'''(double x, double y, QString name);
 
void '''rotateObject'''(double rot, QString name);
 
void '''rotateObjectAbs'''(double rot, QString name);
 
void '''sizeObject'''(double width, double height, QString name);
 
QString '''getSelectedObject'''(int nr);
 
long '''selectionCount'''();
 
void '''selectObject'''(QString name);
 
void '''deselectAll'''();
 
QString '''groupObjects'''(QList<QVariant> list);
 
void '''unGroupObjects'''(QString name);
 
void '''scaleGroup'''(double factor, QString name);
 
void '''loadImage'''(QString filename, QString name);
 
void '''scaleImage'''(double x, double y, QString name);
 
void '''setImageOffset'''(double x, double y, QString name);
 
void '''setImageScale'''(double x, double y, QString name);
 
void '''setImageBrightness'''(double n, QString name);
 
void '''setImageGrayscale'''(QString name);
 
bool '''lockObject'''(QString name);
 
bool '''isLocked'''(QString name);
 
void '''setScaleImageToFrame'''(bool scaletoframe, bool Proportional, QString name);
 
void '''flipObject'''(bool h, bool v, QString name);
=== Get Properties of objects. ===
QString '''getObjectType'''(QString name);
QString '''getFillColor'''(QString name);
double '''getFillTransparency'''(QString name);
int '''getBlendMode'''(QString name);
QString '''getLineColor'''(QString name);
double '''getLineTransparency'''(QString name);
int '''getLineBlendMode'''(QString name);
int '''getLineWidth'''(QString name);
int '''getLineShade'''(QString name);
int '''getLineJoin'''(QString name);
int '''getLineCap'''(QString name);
int '''getLineStyle'''(QString name);
int '''getFillShade'''(QString name);
int '''getCornerRadius'''(QString name);
QList<QVariant> '''getImageScale'''(QString name);
QString '''getImageName'''(QString name);
 
QList<QVariant> '''getPosition'''(QString name);
QList<QVariant> '''getSize'''(QString name);
int '''getRotation'''(QString name);
QList<QVariant> '''getAllObjects'''();
 
==Page API==
==Color API==


QList<QVariant> '''getColor'''(QString name);
===Methods===
* save
* saveAs(name)
* setInformation(author, title, comment)


QList<QVariant> '''getColorAsCMYK'''(QString name);
====Layer Methods in activeDocument====
* newLayer
* removeLayer
* getActiveLayer
* getActiveLayerName
* setActiveLayer


QList<QVariant> '''getColorAsRGB'''(QString name);
=====Color Methods in activeDocument=====
* newColorCMYK
* newColorRGB
* getColor


void '''changeColorCMYK'''(QString name, int c, int m, int y, int k);
=====Printer method =====
* Printer


void '''changeColorRGB'''(QString name, int r, int g, int b);
=====Image Export methods=====
* supportedImageTypes
* exportAsImages


void '''defineColorCMYK'''(QString name, int c, int m, int y, int k);
===Margins API===
====Properties====
* top
* left
* right
* bottom


void '''defineColorRGB'''(QString name, int r, int g, int b);
===Dimensions API===
====Properties====
* width
* height


void '''deleteColor'''(QString name, QString replace);
===Page API===
====Properties====
* number
* items
* position
* selection
====Methods====
* newRectangle
* newEllipse
* newImage
* newText
* newLine
* placeSVG
* placeODG
* placeEPS
* placeSXD
* savePageAsEPS


void '''replaceColor'''(QString name, QString replace);
===Layer API===
====Properties====
* name
* id
* level
* printable
* viewable
* editable
* flowControl
* outlineMode
* transparency
* blendMode
* active


bool '''isSpotColor'''(QString name);
===Color API===
====Properties====
* name
* spotColor
====Methods====
* changeCMYK
* changeRGB
* replace
* remove


void '''setSpotColor'''(QString name, bool enable);
===Printer API===

Latest revision as of 10:00, 14 June 2013

Scripter2 API is described below. This is a reference for the actual documentation of new scripter.

See also rather : https://scribus-scripter.readthedocs.org/en/latest/

The new Scripter is composed of different modules, which are either accessible externally, or via methods of other apis.

Scripter

Properties

activeDocument

This property return DocumentAPI object.
Usage:
document = Scripter.activeDocument
Here document will represent the active document, and is of type DocumentAPI

activeWindow

This property return WindowAPI object.
Usage:
window = Scripter.activeWindow
Here, window will represent the active window, and is of type WindowAPI. See WindowAPI for methods and properties available for this object.

colors

This property will return a list of default colors in Scribus, each color as an object of ScColorWrapper.
Usage:
colors = Scripter.colors
for i in colors:
print i.name
Result:
Black
Blue
Cool Black
Cyan
Green
Magenta
Red
Registration
Rich Black
Warm Black
White
Yellow

Methods

openDocument

newDocument

Document API

Properties

name

available

margins

modified

activePage

pageCount

activeItem

dimensions

items

selection

selectionCount

colors

layers

masterPages

styles

Methods

  • save
  • saveAs(name)
  • setInformation(author, title, comment)

Layer Methods in activeDocument

  • newLayer
  • removeLayer
  • getActiveLayer
  • getActiveLayerName
  • setActiveLayer
Color Methods in activeDocument
  • newColorCMYK
  • newColorRGB
  • getColor
Printer method
  • Printer
Image Export methods
  • supportedImageTypes
  • exportAsImages

Margins API

Properties

  • top
  • left
  • right
  • bottom

Dimensions API

Properties

  • width
  • height

Page API

Properties

  • number
  • items
  • position
  • selection

Methods

  • newRectangle
  • newEllipse
  • newImage
  • newText
  • newLine
  • placeSVG
  • placeODG
  • placeEPS
  • placeSXD
  • savePageAsEPS

Layer API

Properties

  • name
  • id
  • level
  • printable
  • viewable
  • editable
  • flowControl
  • outlineMode
  • transparency
  • blendMode
  • active

Color API

Properties

  • name
  • spotColor

Methods

  • changeCMYK
  • changeRGB
  • replace
  • remove

Printer API