PDFedit
PDF editor pro UNIX / PDF editor for UNIX

Appendix - Scripting API

Table of Contents

I. Scripting API documentation for PDF Editor
1. Static functions common for GUI and command line
Annotation createAnnotation(double[4] rect,string type);
IProperty createArray()
IProperty createBool(bool value)
PdfOperator createCompositeOperator(string beginText,string endText)
IProperty createDict()
PdfOperator createEmptyOperator()
IProperty createInt(int value)
IPropertyArray createIPropertyArray()
IProperty createName(string value)
PdfOperator createOperator(string text,IPropertyArray parameters)
PdfOperatorStack createPdfOperatorStack()
IProperty createReal(double value)
IProperty createRef(int valueNum,int valueGen)
IProperty createString(string value)
bool delinearize(string inFile,string outFile)
string error()
bool exists(string chkFileName)
string[] functions(bool includeSignatures)
Pdf loadPdf(string name,bool advancedMode)
string[] objects()
void print(string str)
void run(string scriptName,bool skipScriptPath)
void setDebugLevel(string param)
string tr(string text,string context)
void treeNeedReload()
string[] variables()
string version()
2. Static functions in GUI
void processEvents()
void setItemText(string name,string newText)
string getItemText(string name)
void about()
void addAnnotation(Page page,double x1,double y1,double w,double h)
void addObjectDialog(IProperty container)
void checkItem(string name,bool check)
void clearConsole()
void closeAll()
bool closeFile(bool askSave,bool onlyAsk)
void createMenuItem(string parentName,string name,string caption,string action,string accel,string icon,string[] classes=QStringList())
void createNewWindow()
void enableItem(string name,bool enable)
string filename()
string fileOpenDialog()
string fileSaveDialog(string oldName)
Color getColor(string colorName);
string getEditText(string textName)
double getNumber(string name)
void help(string topic)
bool isVisible(string widgetName)
void message(string msg)
Variant mergeDialog()
bool modified()
bool openFile(string name)
void openFileNew(string name)
void options()
Page page()
int pageNumber()
Color pickColor();
Menu popupMenu(string menuName)
bool question(string msg)
int question_ync(string msg)
void restoreWindowState()
bool save()
bool saveCopy(string name)
bool saveRevision()
void saveWindowState()
void setColor(string colorName,Variant newColor)
void setEditText(string textName,string newText)
void setNumber(string name,double number)
void setPredefs(string name,string predefs)
void setPredefs(string name,string[] predefs)
void setRevision(int revision)
void setVisible(string widgetName, bool visible)
void showItem(string name,bool show)
TreeItem treeRoot()
TreeItem treeRootMain()
void warn(string str)
TreeItem firstSelectedItem(string name)
TreeItem nextSelectedItem()
CObject firstSelected(string name)
CObject nextSelected()
QProgressBar * progressBar()
3. Static functions in command line
void exit(int returnCode=0)
string[] parameters()
string takeParameter()
4. Callback functions
onChangeRevision()
onConsoleStart()
onEmptyFile()
onLoad()
onLoadUser()
onLoadError()
onPageChange()
onPageDelete()
onPageRightClick()
onTreeLeftClick()
onTreeRightClick()
onTreeMiddleClick()
onTreeDoubleClick()
onTreeSelectionChange()
onValueChange(name)
5. Objects exported to scripting
settings
string settings.read(string key,string default=NULL)
bool settings.readBool(string key,bool default=false)
string settings.readExpand(string key,string default=NULL)
string settings.expand(string)
string settings.write(string key,string value)
string settings.remove(string key)
void settings.flush()
Document-related objects in scripting
document
6. Object types (common and PDF objects)
Annotation
Dict getDictionary()
Page getPage()
bool remove()
string getType()
string getTypeName()
Array
void add(int index,IProperty ip)
void add(int index,string ip)
void add(int index,int ip)
void add(IProperty ip)
void add(string ip)
void add(int ip)
CObject child(string name)
int count()
void delProperty(int index)
string getText()
CObject property(int index)
CObject
string type()
ContentStream
bool equals(QObject* otherObject)
void deleteOperator(PdfOperator op,bool indicateChange=true)
string getText()
void insertOperator(PdfOperator op,PdfOperator newOp,bool indicateChange=true)
void replace(PdfOperator oldOp,PdfOperator newOp,bool indicateChange=true)
void saveChange()
PdfOperator getFirstOperator()
PdfOperator getLastOperator()
bool isEmpty()
Dict
void add(string name,IProperty ip)
void add(string name,string ip)
void add(string name,int ip)
CObject child(string name)
int count()
void delProperty(string name)
bool exist(string name)
string getText()
CObject property(string name)
CObject propertyDef(string name,int defValue)
CObject propertyDef(string name,string defValue)
string[] propertyNames()
IProperty
bool equals(QObject* otherObject)
Variant value()
string getText()
CObject ref()
int getInt()
string getType()
string getTypeName()
void set(string value)
void set(int value)
void set(double value)
void set(bool value)
IPropertyArray
void append(IProperty prop)
void clear()
int count()
CObject property(int index)
Page
void moveAbove(ContentStream cs)
void moveBelow(ContentStream cs)
void moveAbove(int csi)
void moveBelow(int csi)
void addAnnotation(Annotation an)
void setTransformMatrix(Variant tMatrix)
void prependContentStream(PdfOperatorStack opStack)
void appendContentStream(PdfOperatorStack opStack)
string getFontId(string fontName)
string[] getFontIdsAndNames(bool onlyNames)
void addSystemType1Font(string fontName)
ContentStream getContentStream(int streamNumber)
int getContentStreamCount()
ContentStream getChange(int changeNumber)
int getChangeCount()
void loadContentStreams()
Dict getDictionary()
string getText()
double[] mediabox();
void setMediabox(double x1,double y1,double x2,double y2)
void setMediabox(Rect rc)
Pdf
string encryption()
bool isLinearized()
bool isValid()
void unloadPdf()
bool saveAs(string name)
Dict getDictionary()
void removePage(int position)
int getPagePosition(Page page)
int getPageCount()
Page insertPage(Page page, int position)
Page getPage(int position)
Page getFirstPage()
Page getLastPage()
Page getNextPage(Page page)
Page getPrevPage(Page page)
bool hasNextPage(Page page)
bool hasPrevPage(Page page)
int getRevisionsCount()
int getActualRevision()
PdfOperator
bool equals(QObject* otherObject)
double[4] getBBox ();
PdfOperator getLastOperator()
bool containsNonStrokingOperator()
bool containsStrokingOperator()
PdfOperatorIterator iterator()
PdfOperatorIterator graphicalIterator(bool forwardDir=true)
PdfOperatorIterator inlineImageIterator(bool forwardDir=true)
PdfOperatorIterator textIterator(bool forwardDir=true)
PdfOperatorIterator changeableIterator(bool forwardDir=true)
PdfOperatorIterator strokingIterator(bool forwardDir=true)
PdfOperatorIterator nonStrokingIterator(bool forwardDir=true)
PdfOperatorIterator fontIterator(bool forwardDir=true)
PdfOperatorStack childs()
int childCount()
string getText()
string getName()
IPropertyArray params()
int paramCount()
void pushBack(PdfOperator op,PdfOperator prev)
void remove()
void setNext(PdfOperator op)
void setPrev(PdfOperator op)
PdfOperator clone()
ContentStream stream()
PdfOperatorIterator
PdfOperator current()
PdfOperatorIterator copy()
PdfOperatorIterator next()
PdfOperatorIterator prev()
ContentStream stream()
bool isEnd()
bool isBegin()
bool valid()
PdfOperatorStack
int count()
void append(PdfOperator prop)
void prepend(PdfOperator prop)
CObject first()
CObject last()
void removeFirst()
void removeLast()
CObject element(int index)
Stream
void setBuffer(ByteArray a)
void setBuffer(string s)
void setRawBuffer(ByteArray a)
void setRawBuffer(string s)
bool loadBuffer(string fileName)
bool loadRawBuffer(string fileName)
string getBufferString()
ByteArray getBuffer()
bool saveBuffer(string fileName)
string getDecoded()
7. Object types (GUI objects)
Menu
string popup()
void reset()
void addItemDef(string def)
void addItem(string name)
void addSeparator()
TreeItem
void setSelected(bool selected=true)
bool selected()
bool valid()
void setOpen(bool opened)
CObject item()
CObject itemref()
string itemtype()
TreeItem child(string name)
string[] getChildNames()
TreeItem parent()
string id()
string text()
string path()
void reload()
void remove()
TreeItemContentStream
void setMode(string newMode)
string getMode()
8. QSA Utility Framework
File Class Reference
Enums
Static Functions
Constructor
Properties
Member Functions
Dir Class Reference
Enums
Static Properties
Static Functions
Constructor
Properties
Member Functions
Process Class Reference
Static Properties
Static Functions
Constructor
Properties
Member Functions
9. QSA Input Dialog Framework
CheckBox
Properties
ComboBox
Properties
DateEdit
Properties
Dialog
Properties
Functions
GroupBox
Properties
Functions
LineEdit
Properties
NumberEdit
Properties
RadioButton
Properties
SpinBox
Properties
TextEdit
Properties
TimeEdit
Properties
Convenience Classes
The MessageBox class
Button types
Functions
The FileDialog class
Functions
The Input class
Functions

List of Tables

5.1. List of internal variables

Scripting API documentation for PDF Editor

Table of Contents

1. Static functions common for GUI and command line
Annotation createAnnotation(double[4] rect,string type);
IProperty createArray()
IProperty createBool(bool value)
PdfOperator createCompositeOperator(string beginText,string endText)
IProperty createDict()
PdfOperator createEmptyOperator()
IProperty createInt(int value)
IPropertyArray createIPropertyArray()
IProperty createName(string value)
PdfOperator createOperator(string text,IPropertyArray parameters)
PdfOperatorStack createPdfOperatorStack()
IProperty createReal(double value)
IProperty createRef(int valueNum,int valueGen)
IProperty createString(string value)
bool delinearize(string inFile,string outFile)
string error()
bool exists(string chkFileName)
string[] functions(bool includeSignatures)
Pdf loadPdf(string name,bool advancedMode)
string[] objects()
void print(string str)
void run(string scriptName,bool skipScriptPath)
void setDebugLevel(string param)
string tr(string text,string context)
void treeNeedReload()
string[] variables()
string version()
2. Static functions in GUI
void processEvents()
void setItemText(string name,string newText)
string getItemText(string name)
void about()
void addAnnotation(Page page,double x1,double y1,double w,double h)
void addObjectDialog(IProperty container)
void checkItem(string name,bool check)
void clearConsole()
void closeAll()
bool closeFile(bool askSave,bool onlyAsk)
void createMenuItem(string parentName,string name,string caption,string action,string accel,string icon,string[] classes=QStringList())
void createNewWindow()
void enableItem(string name,bool enable)
string filename()
string fileOpenDialog()
string fileSaveDialog(string oldName)
Color getColor(string colorName);
string getEditText(string textName)
double getNumber(string name)
void help(string topic)
bool isVisible(string widgetName)
void message(string msg)
Variant mergeDialog()
bool modified()
bool openFile(string name)
void openFileNew(string name)
void options()
Page page()
int pageNumber()
Color pickColor();
Menu popupMenu(string menuName)
bool question(string msg)
int question_ync(string msg)
void restoreWindowState()
bool save()
bool saveCopy(string name)
bool saveRevision()
void saveWindowState()
void setColor(string colorName,Variant newColor)
void setEditText(string textName,string newText)
void setNumber(string name,double number)
void setPredefs(string name,string predefs)
void setPredefs(string name,string[] predefs)
void setRevision(int revision)
void setVisible(string widgetName, bool visible)
void showItem(string name,bool show)
TreeItem treeRoot()
TreeItem treeRootMain()
void warn(string str)
TreeItem firstSelectedItem(string name)
TreeItem nextSelectedItem()
CObject firstSelected(string name)
CObject nextSelected()
QProgressBar * progressBar()
3. Static functions in command line
void exit(int returnCode=0)
string[] parameters()
string takeParameter()
4. Callback functions
onChangeRevision()
onConsoleStart()
onEmptyFile()
onLoad()
onLoadUser()
onLoadError()
onPageChange()
onPageDelete()
onPageRightClick()
onTreeLeftClick()
onTreeRightClick()
onTreeMiddleClick()
onTreeDoubleClick()
onTreeSelectionChange()
onValueChange(name)
5. Objects exported to scripting
settings
string settings.read(string key,string default=NULL)
bool settings.readBool(string key,bool default=false)
string settings.readExpand(string key,string default=NULL)
string settings.expand(string)
string settings.write(string key,string value)
string settings.remove(string key)
void settings.flush()
Document-related objects in scripting
document
6. Object types (common and PDF objects)
Annotation
Dict getDictionary()
Page getPage()
bool remove()
string getType()
string getTypeName()
Array
void add(int index,IProperty ip)
void add(int index,string ip)
void add(int index,int ip)
void add(IProperty ip)
void add(string ip)
void add(int ip)
CObject child(string name)
int count()
void delProperty(int index)
string getText()
CObject property(int index)
CObject
string type()
ContentStream
bool equals(QObject* otherObject)
void deleteOperator(PdfOperator op,bool indicateChange=true)
string getText()
void insertOperator(PdfOperator op,PdfOperator newOp,bool indicateChange=true)
void replace(PdfOperator oldOp,PdfOperator newOp,bool indicateChange=true)
void saveChange()
PdfOperator getFirstOperator()
PdfOperator getLastOperator()
bool isEmpty()
Dict
void add(string name,IProperty ip)
void add(string name,string ip)
void add(string name,int ip)
CObject child(string name)
int count()
void delProperty(string name)
bool exist(string name)
string getText()
CObject property(string name)
CObject propertyDef(string name,int defValue)
CObject propertyDef(string name,string defValue)
string[] propertyNames()
IProperty
bool equals(QObject* otherObject)
Variant value()
string getText()
CObject ref()
int getInt()
string getType()
string getTypeName()
void set(string value)
void set(int value)
void set(double value)
void set(bool value)
IPropertyArray
void append(IProperty prop)
void clear()
int count()
CObject property(int index)
Page
void moveAbove(ContentStream cs)
void moveBelow(ContentStream cs)
void moveAbove(int csi)
void moveBelow(int csi)
void addAnnotation(Annotation an)
void setTransformMatrix(Variant tMatrix)
void prependContentStream(PdfOperatorStack opStack)
void appendContentStream(PdfOperatorStack opStack)
string getFontId(string fontName)
string[] getFontIdsAndNames(bool onlyNames)
void addSystemType1Font(string fontName)
ContentStream getContentStream(int streamNumber)
int getContentStreamCount()
ContentStream getChange(int changeNumber)
int getChangeCount()
void loadContentStreams()
Dict getDictionary()
string getText()
double[] mediabox();
void setMediabox(double x1,double y1,double x2,double y2)
void setMediabox(Rect rc)
Pdf
string encryption()
bool isLinearized()
bool isValid()
void unloadPdf()
bool saveAs(string name)
Dict getDictionary()
void removePage(int position)
int getPagePosition(Page page)
int getPageCount()
Page insertPage(Page page, int position)
Page getPage(int position)
Page getFirstPage()
Page getLastPage()
Page getNextPage(Page page)
Page getPrevPage(Page page)
bool hasNextPage(Page page)
bool hasPrevPage(Page page)
int getRevisionsCount()
int getActualRevision()
PdfOperator
bool equals(QObject* otherObject)
double[4] getBBox ();
PdfOperator getLastOperator()
bool containsNonStrokingOperator()
bool containsStrokingOperator()
PdfOperatorIterator iterator()
PdfOperatorIterator graphicalIterator(bool forwardDir=true)
PdfOperatorIterator inlineImageIterator(bool forwardDir=true)
PdfOperatorIterator textIterator(bool forwardDir=true)
PdfOperatorIterator changeableIterator(bool forwardDir=true)
PdfOperatorIterator strokingIterator(bool forwardDir=true)
PdfOperatorIterator nonStrokingIterator(bool forwardDir=true)
PdfOperatorIterator fontIterator(bool forwardDir=true)
PdfOperatorStack childs()
int childCount()
string getText()
string getName()
IPropertyArray params()
int paramCount()
void pushBack(PdfOperator op,PdfOperator prev)
void remove()
void setNext(PdfOperator op)
void setPrev(PdfOperator op)
PdfOperator clone()
ContentStream stream()
PdfOperatorIterator
PdfOperator current()
PdfOperatorIterator copy()
PdfOperatorIterator next()
PdfOperatorIterator prev()
ContentStream stream()
bool isEnd()
bool isBegin()
bool valid()
PdfOperatorStack
int count()
void append(PdfOperator prop)
void prepend(PdfOperator prop)
CObject first()
CObject last()
void removeFirst()
void removeLast()
CObject element(int index)
Stream
void setBuffer(ByteArray a)
void setBuffer(string s)
void setRawBuffer(ByteArray a)
void setRawBuffer(string s)
bool loadBuffer(string fileName)
bool loadRawBuffer(string fileName)
string getBufferString()
ByteArray getBuffer()
bool saveBuffer(string fileName)
string getDecoded()
7. Object types (GUI objects)
Menu
string popup()
void reset()
void addItemDef(string def)
void addItem(string name)
void addSeparator()
TreeItem
void setSelected(bool selected=true)
bool selected()
bool valid()
void setOpen(bool opened)
CObject item()
CObject itemref()
string itemtype()
TreeItem child(string name)
string[] getChildNames()
TreeItem parent()
string id()
string text()
string path()
void reload()
void remove()
TreeItemContentStream
void setMode(string newMode)
string getMode()
8. QSA Utility Framework
File Class Reference
Enums
Static Functions
Constructor
Properties
Member Functions
Dir Class Reference
Enums
Static Properties
Static Functions
Constructor
Properties
Member Functions
Process Class Reference
Static Properties
Static Functions
Constructor
Properties
Member Functions
9. QSA Input Dialog Framework
CheckBox
Properties
ComboBox
Properties
DateEdit
Properties
Dialog
Properties
Functions
GroupBox
Properties
Functions
LineEdit
Properties
NumberEdit
Properties
RadioButton
Properties
SpinBox
Properties
TextEdit
Properties
TimeEdit
Properties
Convenience Classes
The MessageBox class
Button types
Functions
The FileDialog class
Functions
The Input class
Functions

Chapter 1. Static functions common for GUI and command line

Annotation createAnnotation(double[4] rect,string type);

Creates and initializes new annotation of given type. Parameter rect specifies annotation rectangle in default user space units.

IProperty createArray()

Creates and returns new IProperty of type Array - empty array

IProperty createBool(bool value)

Creates and returns new IProperty of type Bool

PdfOperator createCompositeOperator(string beginText,string endText)

Creates new composite PDF Operator with specified starting and ending operator text

IProperty createDict()

Creates and returns new IProperty of type Dict - empty dictionary

PdfOperator createEmptyOperator()

Creates new empty (NULL) PDF Operator

IProperty createInt(int value)

Creates and returns new IProperty of type Int

IPropertyArray createIPropertyArray()

Creates new array of IProperty items. This array can be used for example as operator parameters

IProperty createName(string value)

Creates and returns new IProperty of type String

PdfOperator createOperator(string text,IPropertyArray parameters)

Creates new PDF Operator with specified operator text and parameters

PdfOperatorStack createPdfOperatorStack()

Create new empty PDF Operator stack

IProperty createReal(double value)

Creates and returns new IProperty of type Real

IProperty createRef(int valueNum,int valueGen)

Creates and returns new IProperty of type Ref. Does not check validity of the values (if the reference target exists, etc ...)

IProperty createString(string value)

Creates and returns new IProperty of type String

bool delinearize(string inFile,string outFile)

Tries to delinearize PDF, reading from input file and writing delinearized result to output file. Does not check for overwriting output. Returnis true if delinearization was successful, false in case of failure. In case of failure the error mesage is available via error() function.

string error()

Returns last error message (localized) from some operations (openFile, save, saveRevision, saveCopy, delinearize)

bool exists(string chkFileName)

Returns true if given file exists on disk, false otherwise

string[] functions(bool includeSignatures)

Debugging function usable by script developers. Returns list of all functions that are present in current script interpreter. Functions are sorted alphabetically. If includeSignatures is set, function signatures are returned, otherwise only names

Pdf loadPdf(string name,bool advancedMode)

Loads a PDF file without replacing currently opened file in GUI. Scripts can manipulate the PDF file as necessary, but should close it with unloadPdf() method after it don't need to use it anymore. If advancedMode is set to true, document is opened in "advanced mode" (more advanced, but also more dangerous changes to it are possible)

string[] objects()

Debugging function usable by script developers. Returns list of all objects that are in current script interpreter

void print(string str)

Outputs given string to command window, followed by newline. Useful to output various debugging or status messages

void run(string scriptName,bool skipScriptPath)

Loads and runs script from given filename. File is looked for in the script path, unless absolute filename is given or parameter skipScriptPath is specified. If the file is not found in script path, it is searched in current directory.

void setDebugLevel(string param)

Sets new debugging verbosity level. Accepts same parameter as -d option on commandline (either number or symbolic constant).

string tr(string text,string context)

Translates given text to current locale. Optional parameter context can specify context of localized text. Returns translated text.

void treeNeedReload()

You can call this to explicitly request the tree to reload after the script finishes execution.

string[] variables()

Debugging function usable by script developers. Returns sorted list of all variables that are in current script interpreter.

string version()

Returns version of editor (in format 'major.minor.release')

Chapter 2. Static functions in GUI

Table of Contents

void processEvents()
void setItemText(string name,string newText)
string getItemText(string name)
void about()
void addAnnotation(Page page,double x1,double y1,double w,double h)
void addObjectDialog(IProperty container)
void checkItem(string name,bool check)
void clearConsole()
void closeAll()
bool closeFile(bool askSave,bool onlyAsk)
void createMenuItem(string parentName,string name,string caption,string action,string accel,string icon,string[] classes=QStringList())
void createNewWindow()
void enableItem(string name,bool enable)
string filename()
string fileOpenDialog()
string fileSaveDialog(string oldName)
Color getColor(string colorName);
string getEditText(string textName)
double getNumber(string name)
void help(string topic)
bool isVisible(string widgetName)
void message(string msg)
Variant mergeDialog()
bool modified()
bool openFile(string name)
void openFileNew(string name)
void options()
Page page()
int pageNumber()
Color pickColor();
Menu popupMenu(string menuName)
bool question(string msg)
int question_ync(string msg)
void restoreWindowState()
bool save()
bool saveCopy(string name)
bool saveRevision()
void saveWindowState()
void setColor(string colorName,Variant newColor)
void setEditText(string textName,string newText)
void setNumber(string name,double number)
void setPredefs(string name,string predefs)
void setPredefs(string name,string[] predefs)
void setRevision(int revision)
void setVisible(string widgetName, bool visible)
void showItem(string name,bool show)
TreeItem treeRoot()
TreeItem treeRootMain()
void warn(string str)
TreeItem firstSelectedItem(string name)
TreeItem nextSelectedItem()
CObject firstSelected(string name)
CObject nextSelected()
QProgressBar * progressBar()

void processEvents()

Allow application to process its events, so the gui can redraw itself. Useful, it it is called periodically while doing some lenthy operation

void setItemText(string name,string newText)

Set text of all menu and toolbar items with given name to specified string. The string will be transtated according to the translation file, so it is suggested to supply english text and add corresponding localized translation into the localization file.

string getItemText(string name)

Get text of menu or toolbar item with given name. Returns untranslated (english) string, even when the application is run using another language translation. When setting back the same string, it will be re-translated according to translation file, if different GUI language is selected

void about()

Invokes "About" dialog, showing information about this program and its authors

void addAnnotation(Page page,double x1,double y1,double w,double h)

Creates dialog for annotations creation. Parameter page is page in which the annotation will be added (x1,y1) are coordinated of lower left point of annotation rectangle. W is the rectangle widht and h is its height Returns after annotation have been inserted into page, or dialog have been cancelled

void addObjectDialog(IProperty container)

Invokes dialog for adding additional objects to specified container (which must be Dictionary or Array). After invoking dialog, this function returns immediately and the dialog is left for the user to use. If given object is not specified, curently selected object in property editor is used. If the object is not Dictionary or Array, no dialog is shown.

void checkItem(string name,bool check)

Check (second parameter is true) or uncheck (false) item in toolbar and/or menu, given its name If you prefix name with slash ("/"), you will affect "class" of items - every item that belong to the specified class

Note

Toolbuttons will automatically convert to Togglable toolbuttons this way and will start togling itself automatically on each succesive click

void clearConsole()

Clear the console output window

void closeAll()

Closes all windows (and thus ends application)

bool closeFile(bool askSave,bool onlyAsk)

Closes file opened in this editor window. if askSave is true, user is asked to save the file if it is modified. if onlyAsk is true, file is not actually closed, only user is asked if he want to save work (if not specified, defaults to false). returns true in case of success, or false if user decide not to close current document and keep it open.

void createMenuItem(string parentName,string name,string caption,string action,string accel,string icon,string[] classes=QStringList())

Load one menu or toolbar item and insert it into parent menu or toolbar. If the name is "" or "-", separator is inserted on place of the item and rest of parameters are ignored. If inserting item into toolbar and the name will match one of the special items, the special item will be inserted in toolbar and rest of the parameters are ignored. Items that are loaded from settings have theyir name equal to the key in setting they are stored under.
parentNameName of parent menu/toolbar. If NULL/empty, main menubar is the parent
name Name of the item. Must be unique.
caption Caption of item
action Script to execute when the item is selected
accel Keyboard accelerator
icon Name of icon to use
classes List of item classes

void createNewWindow()

Creates new editor window with empty document in it.

void enableItem(string name,bool enable)

Enable (second parameter is true) or disable (false) item in toolbar and/or menu, given its name If you prefix name with slash ("/"), you will enable or disable "class" of items - every item that belong to the specified class

string filename()

Return name of file loaded in editor window. If the file does not exist on disk (not loaded any file, or file was never saved, having no name), empty string is returned.

string fileOpenDialog()

Invokes "open file" dialog and return selected filename, or NULL if dialog was cancelled

string fileSaveDialog(string oldName)

Invokes "save file" dialog and return selected filename, or NULL if dialog was cancelled. If file selected in dialog already exists, user is asked to confirm overwriting before returing its name.

Color getColor(string colorName);

Get color from color picker with given name. Returns false if the color picker does not exist.

string getEditText(string textName)

Get text from editbox or text selection box in toolbar with given name. Returns false if the box does not exist.

double getNumber(string name)

Get number from number editbox in toolbar with given name. Returns 0 if the number editbox does not exist.

void help(string topic)

Invokes program help. Optional parameter is topic - if invalid or not defined, help title page will be invoked

bool isVisible(string widgetName)

Check if part of the window is visible (returns true) or hidden (returns false) widgetName specifies which part:
commandline Command line
rightside Right side tools (Tree Window and property editor)
propertyeditor Property editor
tree Tree window
statusbar Statusbar

void message(string msg)

Show simple messagebox with specified message and wait until user dismiss it

Variant mergeDialog()

Bring up "merge pages from another PDF in this document" dialog. Returns result of merge or NULL if dialog was cancelled Result is array of three elements:
  • First element is array with page numbers

  • Second element is array with page positions

  • Third is filename of the document to be merged in

bool modified()

Return true if the document was modified since it was opened or last saved, false otherwise.

bool openFile(string name)

Opens file with given name in this editor window. Opens without any questions, does not ask user to save changes to current file, etc ... Return true on success, false on failure to load file.

void openFileNew(string name)

Opens file with given name in new editor window

void options()

Invokes options dialog. Does not wait for dialog to be closed by user and return immediately.

Page page()

Return currently shown page

int pageNumber()

Return page number of currently shown page

Color pickColor();

Invoke dialog to select color and return the color that user have picked, or false if user cancelled the dialog.

Menu popupMenu(string menuName)

Create and return a Menu object. The menuName parameter specifies name of item or list from configuration, that will be used to initially fill the menu with items. If this parameter is not specified or invalid, the menu will be initially empty. See documentation for Menu object type for more info about using popup menus.

bool question(string msg)

Show Yes/No question and wait for answer. Return true if user selected "yes", or false if user selected "no"

int question_ync(string msg)

Show Yes/No/Cancel question and wait for answer. Return 1 if user selected "yes", 0 if user selected "no", -1 if user cancelled dialog (selecting Cancel)

void restoreWindowState()

Restore state of current editor window (size and position of window and elements inside it) State is restored from state saved in editor's configuration file.

bool save()

Save currently edited document. If current document have no name, user will be asked for name. If it is not possible to ask user or user presses cancel in file chooser, document is not saved. Return true if document was saved, false if it was not saved for any reason (file write error, user refused to give filename on new file ...)

bool saveCopy(string name)

Save currently edited document (with currently active revision) under different name. Return true if document was saved, false if it failed to save for any reason

bool saveRevision()

Save currently edited document, while creating new revision in the process. Return true if document was saved, false if it was not saved for any reason.

void saveWindowState()

Save state of current editor window (size and position of window and elements inside it) State is saved to editor's configuration file.

void setColor(string colorName,Variant newColor)

Set color of color picker with given name

void setEditText(string textName,string newText)

Set text in toolbar editbox with given name or set selection in text selection box. If you specify string that is not one of the items in the selection box, the current item will remain selected.

void setNumber(string name,double number)

Set number in toolbar number editbox with given name

void setPredefs(string name,string predefs)

Set list of predefined values for number edit box or select text box with given name. The values in the list must be separated by commas. For number edit box, the user is still able to type in any value not in the list.

void setPredefs(string name,string[] predefs)

Set list of predefined values for number edit box or select text box with given name. For number edit box, the user is still able to type in any value not in the list.

void setRevision(int revision)

Change active revision in current PDF document

void setVisible(string widgetName, bool visible)

Set part of the window to be either visible or invisible, widgetName specifies which part, see isVisible for list of possible names.

void showItem(string name,bool show)

Show (second parameter is true) or hide (false) item in toolbar, given its name If you prefix name with slash ("/"), you will affect "class" of items - every item that belong to the specified class

TreeItem treeRoot()

Return root item of currently selected tree