wiki:ITERATION_12/Release/UserDocumentation/SophieAuthor/10_WorkingWithScripting/01_BasicDocumentation
Last modified 16 years ago Last modified on 09/29/09 17:00:55

Error: Macro BackLinksMenu(None) failed
compressed data is corrupt

10.1. Sophie 2 scripting API documentation

(This is still incomplete.)

Class name: Book

  • A global variable book is available which represents the book where the script is inserted.
  • Users can create new books and later manipulate them.
    • Example: var b = app.newBook()

Properties

Property Type Description Examples
title string Book's title Set the book title to "Demonstration Book":
book.title = 'Demonstration Book';
pages array of Page All pages in the book Getting the number of pages in the current book:
var booklength = book.pages.length;
pageSize ImmSize Page's dimensions Getting the page height:
var height = book.pageSize.height;

Setting new dimensions:
book.pageSize = new ImmSize(600, 900);

Methods

Method Description Example
function newPage() Creates a new page in the book and returns it Add new page after existing pages:
book.newPage();
function removePage(index) Removes the page with the given index. The first page has an index 0 (not 1) Delete last page:
b.removePage(b.pages.length - 1);
function movePage(oldIndex, newIndex) Moves the page with index oldIndex to index newIndex Move the first page after the second:
book.movePage(0, 1);
setCurrentPage(page) Sets the given page as the current page

Class name: Page

Properties

Property Type Description Example
pageNumber integer Gets the number of the page. First page has a number 1. Page number cannot be changed.
pageIndex integer Gets the index of the page. First page has an index 0. Page index cannot be changed.
name string Gets the name of the page, for example "Page A"
frames array of Frame All frames in the page Getting the number of frames in first page:
book.pages[0].frames.length;

Methods

Method Description Example
newTextFrame() Creates a new text frame in the page and returns it.
removeFrame(frame) Removes the given frame Remove first frame in a page:
page.removeFrame(page.frames[0]);

Class name: Frame

Properties

Property Type Description Example
name string Gets the name of the frame
size ImmSize The outer size of the frame Set the frame's size to be the same as the page's size (without moving it to the top-left corner):
book.pages[0].frames[0].size = book.pageSize;
zOrder integer The z-order of the frame. The bottom-most frame has z-order 0, the front-most has the biggest z-order Swap a frame with the frame above it:
frame.zOrder++;
contentLocation ImmPoint The location (the coordinates) of the frame content
rotatingAngle double The angle at which the frame is rotated. The value is in degrees.

Methods

Method Description
function bringToFront() moves the frame above all other page elements.
function bringToBack() moves the frame below all other page elements.