## Page related Commands

applyMasterPage(...)
  `applyMasterPage(masterPageName, pageNr)`

  Applies the named master page to the indicated page. Some examples of usage are on the wiki..

closeMasterPage(...)
  `closeMasterPage()`

  Closes the currently active master page, if any, and returns editing to normal. Begin editing with editMasterPage().

createMasterPage(...)
  `createMasterPage(pageName)`

  Creates a new master page named pageName. Begin editing with editMasterPage().

currentPage(...)
  `currentPage() -> integer`

  Returns the number of the current working page. Page numbers are counted from 1 upwards, no matter what the displayed first page number of your document is.

  If you want to enter into a text frame the special character for the current page number, it is decimal 30 or hex 0x1e. For example, either of the following would be equivalent:

  scribus.setText('Page ' + chr(30), textframe)

  scribus.setText('Page \x1e', textframe)

  See also pageCount()

deleteMasterPage(...)
  `deleteMasterPage(pageName)`

  Delete the named master page.

deletePage(...)
  `deletePage(nr)`

  Deletes the given page. Does nothing if the document contains only one page. Page numbers are counted from 1 upwards, no matter what the displayed first page number is.

  May raise IndexError if the page number is out of range

editMasterPage(...)
  `editMasterPage(pageName)`

  Enables master page editing and opens the named master page for editing. Finish editing with closeMasterPage().

getAllObjects(...)
  `getAllObjects([type, page, "layer"]) -> list`

  Returns a list containing the names of all objects of specified type and located on specified page and/or layer.

  This function accepts several optional keyword arguments:

  - type (optional): integer corresponding to item type, by default all items will be returned. You can use one of the ITEMTYPE_* constants.
  - page (optional): index of page on which returned objects are located, by default the current page. The page index starts at 0 and goes to the total number of pages - 1.
  - "layer" (optional): name of layer on which returned objects are located, by default the function returns items located on all layers.

  May throw ValueError if page index or layer name is invalid.

getHGuides(...)
  `getHGuides() -> list`

  Returns a list containing positions of the horizontal guides. Values are in the document's current units - see UNIT_<type> constants.

getMasterPage(...)
  `getMasterPage(nr) -> string`

  Returns the name of master page applied to page "nr".

  May raise IndexError if the page number is out of range.

getPageType(...)
  `getPageType() -> integer`

  Returns the type of the Page, 0 means left Page, 1 is a middle Page and 2 is a right Page

getPageItems(...)
  `getPageItems() -> list`

  Returns a list of tuples with items on the current page. The tuple is: (name, objectType, order) E.g. [('Text1', 4, 0), ('Image1', 2, 1)] means that object named 'Text1' is a text frame (type 4) and is the first at the page...

getPageMargins(...)
  `getPageMargins()`

  Returns the document page margins as a (top, left, right, bottom) tuple in the document's current units. See UNIT_<type> constants and getPageSize().

getPageNMargins(...)
  `getPageNMargins(nr)`

  Returns a tuple with a particular page's margins measured in the document's current units. See UNIT_<type> constants and getPageSize().

getPageSize(...)
  `getPageSize() -> tuple`

  Returns a tuple with document page dimensions measured in the document's current units. See UNIT_<type> constants and getPageMargins()

getPageNSize(...)
  `getPageNSize(nr) -> tuple`

  Returns a tuple with a particular page's size measured in the document's current units. See UNIT_<type> constants and getPageMargins()

getVGuides(...)
  `getVGuides()`

  See getHGuides.

gotoPage(...)
  `gotoPage(nr)`

  Moves to the page "nr" (that is, makes the current page "nr"). Note that gotoPage doesn't (currently) change the page the user's view is displaying, it just sets the page that script commands will operates on.

  May raise IndexError if the page number is out of range.

importPage(...)
  `importPage("fromDoc", (pageList), [create, importWhere, importWherePage])`

  Imports a set of pages (given as a tuple) from an existing document (the file name must be given). This function maps the "Page->Import" dropdown menu function.

  The function accepts following arguments:

  - fromDoc: string; the filename of the document to import pages from
  - pageList: tuple; page numbers of pages to import
  - create: number; 0 to replace existing pages, 1 (default) to insert new pages
  - importWhere: number; used if create==1; 0 to create pages before importWherePage, 1 to create pages after importWherePage, 2 (default) to create pages at the end of the document
  - importWherePage: number; used if create==1 and importWhere==0|1; zero-based page number (of the current document) before or after which to import the pages
newPage(...)
  `newPage(where [,"masterpage"])`

  Creates a new page. If "where" is -1 the new Page is appended to the document, otherwise the new page is inserted before "where". Page numbers are counted from 1 upwards, no matter what the displayed first page number of your document is. The optional parameter "masterpage" specifies the name of the master page for the new page.

  May raise IndexError if the page number is out of range

pageCount(...)
  `pageCount() -> integer`

  Returns the number of pages in the document.

  There is also a special character for page count, in decimal 23, and in hex 0x17. You might combine this with the special character for current page in a text frame (on a Master Page for example) as follows. Either of these is equivalent:

  scribus.setText('Page ' + chr(30) + ' of ' + chr(23), textframe)

  scribus.setText('Page \x1e of \x17', textframe)

redrawAll(...)
  `redrawAll()`

  Redraws all pages.

savePageAsEPS(...)
  `savePageAsEPS("name")`

  Saves the current page as an EPS to the file "name".

  May raise ScribusError if the save failed.

setHGuides(...)
  `setHGuides(list)`

  Sets horizontal guides. Input parameter must be a list of guide positions measured in the current document units - see UNIT_<type> constants.

  Example:

  setHGuides(getHGuides() + [200.0, 210.0]) # this will add new guides while saving existing guides

  setHGuides([90,250]) # this will replace current guides entirely

setRedraw(...)
  `setRedraw(bool)`

  Disables page redraw when bool = False, otherwise redrawing is enabled. This change will persist even after the script exits, so make sure to call setRedraw(True) in a finally: clause at the top level of your script.

setVGuides(...)
  `setVGuides()`

  The usage is analogous to that of setHGuides for either adding to existing guides or replacing them.