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
- 4. Callback functions
- 5. Objects exported to scripting
- 6. Object types (common and PDF objects)
- Annotation
- Array
- CObject
- 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
- IPropertyArray
- 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)
- 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
- PdfOperatorStack
- Stream
- 7. Object types (GUI objects)
- 8. QSA Utility Framework
- 9. QSA Input Dialog Framework
List of Tables
List of Examples
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
- 4. Callback functions
- 5. Objects exported to scripting
- 6. Object types (common and PDF objects)
- Annotation
- Array
- CObject
- 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
- IPropertyArray
- 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)
- 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
- PdfOperatorStack
- Stream
- 7. Object types (GUI objects)
- 8. QSA Utility Framework
- 9. QSA Input Dialog Framework
Table of Contents
- 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()
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()
Note
Toolbuttons will automatically convert to Togglable toolbuttons this way and will start togling itself automatically on each succesive clickparentName | Name 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 |
commandline | Command line |
rightside | Right side tools (Tree Window and property editor) |
propertyeditor | Property editor |
tree | Tree window |
statusbar | Statusbar |
First element is array with page numbers
Second element is array with page positions
Third is filename of the document to be merged in
Table of Contents
These are functions called from editor on certain events. Return value (if any) is ignored. If the callback function does not exist, it is skipped
This function is called in commandline mode after calling all scripts specified in commanline parameters - unless some of the scripts exit the application prematurely, for example by calling exit().
This function is called after the editor is opened without specifying any document on commandline (without opening any file) or if the current file is closed.
This function is called after document is opened (after onLoad() is called)
This function is called after clicking with right mouse button in window with page preview.
This function is called after clicking with left mouse button on any item in tree window.
This function is called after clicking with right mouse button on any item in tree window.
This function is called after clicking with middle mouse button on any item in tree window.
This function is called after doubleclicking with left mouse button on any item in tree window.
This function is called after some of special tools change its value because of interaction. Parameter is name of the special tool. Color selection tool calls this after user select some color in it, edit tool calls this after user presses enter or leaves the control, number tool calls this after user presses enter or selects some of predefined numbers, select tool calls this after changing the selection.
Table of Contents
This object hold application settings and can be used to read or write them.
Note
Some internal variables (all of them beginning with $PDFEDIT_) can override corresponding environment variables. This function will use the internal variable in expansion if both internal and environment variables exist.These objects are set to reflect currently edited document
This object represents currently edited PDF document. Type of this object is Pdf
Table of Contents
- Annotation
- Array
- CObject
- 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
- IPropertyArray
- 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)
- 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
- PdfOperatorStack
- Stream
Ancestor type: CObject
This type represent one annotation in page
Ancestor type: IProperty
This type represents an array in PDF document. It hold zero or more values indexed by positive integer, starting from zero. Values can be of any type, either simple types (int, bool, float, string) or complex types (Dict, Array)
Base class for all PDF objects used in scripts
Ancestor type: CObject
This type of object represents content stream in document (in page)
Ancestor type: IProperty
This type represents a dictionary in PDF document. It hold keys (String) and values. Each key is corresponding to one value. Keys are strings, values can be of any type, either simple types (int, bool, float, string) or complex types (Dict, Array)
Ancestor type: CObject
This object represent one property in dictionary or array
Ancestor type: CObject
This type represents arbitrary array of IProperty items It hold zero or more values indexed by positive integer, starting from zero. Values can be of any type, either simple types (int, bool, float, string) or complex types (Dict, Array)
Ancestor type: CObject
This type of object represents one page in document.
Ancestor type: CObject
This type of object represents entire document. Note to page manipulation - page number start from number 1, number of last page is equal to count of pages
Ancestor type: CObject
This type of object represents pdf operator in content stream
Ancestor type: CObject
This type of object represents pdf operator in content stream
Ancestor type: CObject
This type represents arbitrary array of PDFOperator items It hold zero or more values indexed by positive integer, starting from zero. You can add pdf operators to beginning or end of the array, so the array can behave like double-ended stack
Ancestor type: IProperty
This type of object represents stream in document (in page)
Table of Contents
These object types do not have direct corespondence to any object inside PDF document, but some of them may allow you to manipulate them indirectly. Main focus of these types is to interact with user.
Ancestor type: CObject
This type of object represent one popup menu. You can add menu items and submenus to it and you can execute the menu, which will then return the action picked by user (if any) To create new popup menu object, use the popupMenu function
Ancestor type: CObject
This type of object represents one item in treeview. One item in tree usually corespond to one object in PDF document
Ancestor type: TreeItem
This type of object represents one item in treeview representing content stream.
all | Show all operators |
text | Show only text operators |
font | Show only font operators |
graphic | Show only graphic operators |
Table of Contents
File
class provides functionallity for reading and writing
binary and text files. A File
can be instantiated as an object,
giving the scripter complete flexibility when reading and writing files.
In addition, the File
class provides a set of static convenence
functions for reading and writing files in one go.
Typical use of a File
is:
// Reads an entire file in one go var log = File.read('file.log'); // Writes an entire file in one go File.write('copy_of_file.log', log); // Read and write a file line by line var infile = new File('file.log'); infile.open(File.ReadOnly); var outfile = new File('copy_of_file.log'); outfile.open(File.WriteOnly); while (!infile.eof) { var line = infile.readLine(); outfile.write( line ); } infile.close(); outfile.close();
AccessMode
is used in conjunction with File.open
to
specify the mode in which the file is opened.
ReadOnly; Opens the file in read-only mode.
WriteOnly; Opens the file in write-only mode. If this flag is used with
Append,
the file is not truncated; but if used on its own (or withTruncate),
the file is truncated.ReadWrite; Opens the file in read/write mode. The file is not truncated.
Append; Opens the file in append mode. (You must actually use
(WriteOnly | Append)
to make the file writable and to go into append mode.) This mode is very useful when you want to write something to a log file. The file index is set to the end of the file. Note that the result is undefined if you position the file index manually using at() in append mode.Truncate; Truncates the file.
Translate; Enables carriage returns and linefeed translation for text files under Windows.
exists( fileName : String ) : Boolean; Returns true if
fileName
exists; otherwise returns false.remove( fileName : String ); Deletes the file
fileName
if possible; otherwise throws an exception.write( fileName : String, content : String ); Writes the string content to the file
fileName
if possible (completely replacing the original contents if the file already exists); otherwise throws an exception.read( fileName : String ) : String; Reads and returns the contents of the file
fileName
if possible; otherwise throws an exception.isFile( fileName : String ) : Boolean; Returns true if
fileName
is a file; otherwise returns false.isDir( fileName : String ) : Boolean; Returns true if
fileName
is a directory; otherwise returns false.
File( fileName : String ); Creates a file object with the with fileName. If
fileName
is missing or is not a String, an exception is thrown.
name : String; The name of the file including the extension.
path : String; The path of the file.
fullName : String; The fullName of the file, including path, name, and extension.
baseName : String; The name of the file, excluding its path and extension.
extension : String; The file name's extension.
symLink : String; The expansion of the symlink if the file is a symlink; otherwise empty;
exists : Boolean; True if the file exists; otherwise false.
readable : Boolean; True if the file is readable; otherwise false.
writable : Boolean; True if the file is writable; otherwise false.
executable : Boolean; True if the file is executable; otherwise false.
hidden : Boolean; True if the file is hidden; otherwise false.
eof : Boolean; True if reading has reached the end of the file; otherwise false.
created : Date; The creation time of the file.
lastModified : Date; The last modification time of the file.
lastRead : Date; The last time the file was read.
size : Number; The size of the file, in bytes.
open( accessMode : Number ); Opens the file in the mode accessMode if possible; otherwise throws an exception.
close(); Closes the file.
remove((); Deletes the file if possible; otherwise throws an exception.
readByte() : Number; Reads one byte from the file if possible; otherwise throws an exception.
read() : String; Returns the entire content of the file as a string if it can be read; otherwise throws an exception.
readLine() : String; Reads one line from file if possible; otherwise throws an exception. Retains any trailing whitespace.
readLines() : String[]; Returns the contents of the file as an array of Strings, one for each line. Linebreaks are strippped from the strings. If the file could not be read, an exception is thrown.
writeByte( byte : Number ); Writes a byte to the file is possible; otherwise throws an exception.
write( data : String, length : Number ); Writes
length
number of characters fromdata
to the file if possible; otherwise throws an exception.writeLine( data : String ); Writes the line
data
to the file and adds a linebreak. If the file could not be writtenerror
is returned.
Dir
class provides access to directory structures and their
contents in a platform-independent way. It provides a means of listing
directory content, creating filenames with proper path separators,
etc.
An example use of the Dir class is:
var dir = new Dir; var codeFiles = dir.entryList('*.cpp'); for (var i = 0; i < codeFiles.length; ++i) print(codeFiles[i]);
Dirs; List directories only.
Files; List files only.
Drives; List disk drives only.
NoSymLinks; Do not list symbolic links (ignored by operating systems that don't support symbolic links).
All; List directories, files, drives and symlinks (this does not list broken symlinks unless you specify System).
TypeMask; A mask for the the Dirs, Files, Drives and NoSymLinks flags.
Readable; List files for which the application has read access.
Writable; List files for which the application has write access.
Executable; List files for which the application has execute access. Executables must be combined with Dirs or Files.
RWEMask; A mask for the Readable, Writable and Executable flags.
Modified; Only list files that have been modified (ignored under Unix).
Hidden; List hidden files (on Unix, files starting with a .).
System; List system files (on Unix, FIFOs, sockets, and device files)
AccessMask; A mask for the Readable, Writable, Executable Modified, Hidden and System flags
Name; Sort by name.
Time; Sort by time (modification time).
Size; Sort by file size.
Unsorted; Do not sort.
SortByMask; A Mask for Name, Time and Size.
DirsFirst; Put the directories first, then the files.
Reversed; Reverse the sort order.
IgnoreCase; Sort case-insensitively.
current : String; The current directory.
home : String; The home directory.
root : String; The root directory.
drives : String[]; An array of strings containing the drive names (c:, d:, etc); empty on Unix.
cleanDirPath( filePath : String ) : String; Removes all multiple directory separators "/" and resolves any "."s or ".."s found in the path,
filePath.
convertSeparators( pathName : String ) : String; Returns pathName with the "/" separators converted to separators that are appropriate for the underlying operating system.
Dir( path : String ); Creates a directory object for path path. If
path
is empty, the current directory is used.
name : String; Contains the name of the directory; this is not the same as the path, e.g. a directory with the name "mail", might have the path "/var/spool/mail"
path : String; Contains the path, this may contain symbolic links, but never contains redundant ".", "..", or multiple separators.
absPath : String; Contains the absolute path (a path that starts with "/" or with a drive specification), which may contain symbolic links, but never contains redundant ".", "..", or multiple separators.
canonicalPath : String; Contains the canonical path, i.e. a path without symbolic links or redundant "." or ".." elements.
readable : Boolean; True if the directory is readable; otherwise false.
exists : Boolean; True if the directory exists; otherwise false.
filePath( fileName : String ) : String; Returns the path name of the file
fileName
in the directory.absFilePath( fileName : String ) : String; Returns the absolute path name of the file
fileName
in the directory.cd( dirName : String ); Changes the Dir's directory to
dirName
if possible; otherwise throws an exception.cdUp(); Changes directory by moving one directory up from the Dir's current directory if possible; otherwise throws an exception.
entryList( filter : String, filterSpec : Number, sortSpec : Number ) : String[]; Returns a list of the names of all the files and directories in the directory, ordered in accordance with
sortSpec
and filtered in accordance withfilterSpec.
mkdir( dirName : String ); Creates the directory
dirName
if possible; otherwise throws an exception.mkdir(); Creates this directory if possible possible; otherwise throws an exception.
mkdirs( dirName : String ); Creates the directory tree
dirName
if possible; otherwise throws an exception.mkdirs(); Creates this directory tree if possible; otherwise throws an exception.
rmdir( dirName : String ); Deletes the directory
dirName
if possible; otherwise throws an exception.rmdir(); Deletes this directory if possible; otherwise throws an exception.
rmdirs( dirName : String ); Deletes the directory structure dirName if possible; otherwise throws an exception.
rmdirs(); Deletes this directory structure if possible; otherwise throws an exception.
fileExists( fileName : String ) : Boolean; Returns true if the file
fileName
exists; otherwise returns false.setCurrent(); Sets the application's current working directory to this directory if possible; otherwise throws an exception.
Process.execute(),
and asynchronously using
{new
Process(...).start()}.
stdout : String; Contains the data sent to
stdout
during the last call toProcess.execute().
This property is read-only.stderr : String; Contains the data sent to
stderr
during the last call toProcess.execute().
This property is read-only.
execute( command : String, stdin : String ); Executes
command
synchronously and passesstdin
to its standard input if specified. When the program ends its output is accessible through Process.stdout andProcess.stderr.
command
can contain both the program and command line arguments, e.g."ls -la"
. The function returns the executed commands return code on exit.execute( command : String[], stdin : String ); Same as above, except that
command
is an array of strings, where the first item is the name of the program and the following items are command line arguments. This version is useful if you have arguments that contain spaces or other characters that would need to be quoted if you just passed a single string command line, since it takes care of the quoting for you.
Process(); Creates a Process object without specifying the program or any arguments. This does not start a process.
Process( command : String ); Creates a Process object that will execute
command.
This does not start the process.Process( command : String[] ); Same as above, except that command is an array of strings, where the first item is the name of the program and the following items are command line arguments. This version is useful if you have arguments that contain spaces or other characters that would need to be quoted if you just passed a single string command line, since it takes care of the quoting for you.
arguments : String[]; Contains an array of strings where the first item is the program to execute and the following items are the command line arguments.
workingDirectory : String; Contains the working directory for the process.
running : Boolean; True if the process is currently running; otherwise false. This property is read-only.
exitStatus : Number; Contains the exitStatus of the program when it has finished. This property is read-only.
start( env : String[] ); Tries to run a process for the command and arguments that were specified with the
argument
property or that were specified in the constructor. The command is searched for in the path for executable programs; you can also use an absolute path in the command itself. Ifenv
is not specified, the process is started with the same environment as the starting process. Ifenv
is specified, then the values in theenv
stringlist are interpreted as environment setttings of the formVARIABLE=VALUE
and the process is started with these environment settings. If the program could not be started, an exception is thrown.launch( stdin : String, env : String[] ); Runs the process and writes the data
stdin
to the process's standard input. If all the data is written to standard input, standard input is closed. The command is searched for in the path for executable programs; you can also use an absolute path in the command itself. Ifenv
is unspecified, the process is started with the same environment as the starting process. Ifenv
is specified, then the values in the string list are interpreted as environment setttings of the form VARIABLE=VALUE and the process is started with these environment settings. If the program could not be started, an exception is thrown.readStdout() : String; Reads what is currently available on the process's standard output.
readSterr() : String; Reads what is currently available on the process's standard error.
canReadLineStdout() : Boolean; Returns true if a line can be read from the process's standard output.
canReadLineStderr() : Boolean; Returns true if a line can be read from the process's standard error.
readLineStdout() : String; Reads one line of text from the process's standard output if available; otherwise returns an empty string.
readLineStderr() : String; Reads one line of text from the process's standard error if available; otherwise returns an empty string.
tryTerminate(); Asks the process to terminate. Processes can ignore this if they wish. If you want to be certain that the process really terminates, you can use
kill()
instead.kill(); Terminates the process. This is not a safe way to end a process since the process will not be able to do any cleanup.
tryTerminate()
is safer, but processes can ignoretryTerminate().
writeToStdin( buffer : String ); Writes the data
buffer
to the process's standard input. The process may or may not read this data.closeStdin(); Closes the process's standard input.
Table of Contents
var dialog = new Dialog; dialog.caption = "Name reading dialog"; dialog.okButtonText = "Done" dialog.cancelButtonText = "Abort"; var first = new LineEdit; first.label = "First name: "; dialog.add( first ); var last = new LineEdit; last.label = "Last name: "; dialog.add( last ); if( dialog.exec() ) { var fullName = last.text + ", " + first.text; print( "Full name is: " + fullName ); }Below is a list of the classes available from the Input Dialog Framework. Each class has a short description and a list of its properties and functions. For String properties the default is an empty string, and for Number properties the default is 0, unless stated otherwise.
checked : Boolean; This property holds whether the checkbox is checked. The default is unchecked, i.e. false.
text : String; This property holds the text shown on the button.
tooltip : String; This property holds the tool tip (balloon help) for the widget.
whatsThis : String; This property holds a simple description of the widget.
currentItem : String; This property is used in two ways: To specify the default selected item in the combobox; and to get the value the user selected in the combobox when the dialog is closed. The default is the first item in the list.
editable : Boolean; This property holds whether the combobox is editable. The default is false.
itemList : Array; The list of items in the combobox.
label : String; The label for the combobox.
tooltip : String; This property holds the tool tip (balloon help) for the widget.
whatsThis : String; This property holds a simple description of the widget.
date : Date; This property holds the editor's date value. The default is today.
label : String; The label for the date.
maximum : Date; This property holds the editor's maximum value. The default maximum date is 8000-12-31.
minimum : Date; This property holds the editor's minimum value. The default minimum date is 1752-09-14.
order : Order; This property holds the order in which the year, month and day appear. The default order is locale dependent.
tooltip : String; This property holds the tool tip (balloon help) for the widget.
whatsThis : String; This property holds a simple description of the widget.
caption : String; This property holds the window caption (title). The default is the application's name.
cancelButtonText : String; This property holds the text shown on the cancel button. The default is "Cancel".
okButtonText: String; This property holds the text shown on the ok button. The default is "Ok".
width : Number; This property holds the width of the widget excluding any window frame. The default is set by the layout.
tooltip : String; This property holds the tool tip (balloon help) for the widget.
whatsThis : String; This property holds a simple description of the widget.
add( widget : QSWidget ); Adds a widget to the dialog. Widgets are placed vertically, from top to bottom.
addSpace( space : Number ); Adds vertical space, measured in pixels between, the previous and next added widget.
exec() : Boolean; Executes the dialog. This opens the dialog as a modal dialog, blocking the application until the user presses the OK button or the Cancel button to close the dialog. The function returns
true
of the user pressed OK; otherwise it returnsfalse
.newColumn(); Creates a new column in the dialog. All widgets subsequently added to the dialog will be placed (vertically, from top to bottom), in the new column.
newTab( label : String ); Creates a new tab in the dialog with the given label. All widgets subsequently added to the dialog will be placed in the newly created tab, (vertically, from top to bottom).
title : String; This property holds the group box's title text.
tooltip : String; This property holds the tool tip (balloon help) for the widget.
whatsThis : String; This property holds a simple description of the widget.
add( widget : QSWidget ); Adds a widget to this groupbox.
addSpace( space : Number ); Adds vertical space, measured in pixels, between the previous and the next widget that is added.
newColumn(); Creates a new column within this groupbox. All widgets that are added subsequently will be placed in the new column.
addSpace()
decimals : Number; This property holds the number edits's maximum number of digits after the decimal point.
label : String; The label text for this number edit.
maximum : Number; This property holds the number edit's maximum acceptable value. The default is 2,147,483,647.
minimum : Number; This property holds the number edit's minimum acceptable value. The default is -2,147,483,647.
value : Number; This property holds the number edit's input value. The default is 0.
tooltip : String; This property holds the tool tip (balloon help) for the widget.
whatsThis : String; This property holds a simple description of the widget.
checked : Boolean; This property holds whether the radio button is checked. The default is unchecked (false).
text : String; This property holds the text shown on the button.
tooltip : String; This property holds the tool tip (balloon help) for the widget.
whatsThis : String; This property holds a simple description of the widget.
label : String; This property holds the spinbox's label text.
maximum : Number; This property holds the maximum value of the spin box. The default maximum value is 2,147,483,647.
minimum : Number; This property holds the minimum value of the spin box. The default minimum value is -2,147,483,648.
value : Number; This property holds the value of the spin box.
tooltip : String; This property holds the tool tip (balloon help) for the widget.
whatsThis : String; This property holds a simple description of the widget.
label : String; This property holds the time edit's label text.
maximum : Time; This property holds the maximum time value.
minimum : Time; This property holds the minimum time value.
showAMPM : Boolean; If this property is false (the default), the time edit uses the 24 hour clock; otherwise the time edit uses the 12 hour clock and displays AM or PM as appropriate.
showSeconds : Boolean; If this property is true (the default), the time edit displays seconds; otherwise it does not display seconds.
time : Time; This property holds the editor's time value.
tooltip : String; This property holds the tool tip (balloon help) for the widget.
whatsThis : String; This property holds a simple description of the widget.
FileDialog.getOpenFileName().
var ans = MessageBox.warning( "Do you wish to save the data?", MessageBox.Yes, MessageBox.No ); if (ans == MessageBox.Yes) { save(); }
NoButton; No button is displayed.
Ok; Displays an 'OK' button.
Cancel; Displays a 'Cancel' button.
Yes; Displays a 'Yes' button.
No; Displays a 'No' button.
Abort; Displays an 'Abort' button.
Retry; Displays a 'Retry' button.
Ignore; Displays an 'Ignore' button.
information( label : String, button1 : ButtonType, button2 : ButtonType, button3 : ButtonType, title : String ); Displays an information message box with the content specified in
label.
warning( label : String, button1 : ButtonType, button2 : ButtonType, button3 : ButtonType, title : String ); Displays a warning message box with the content specified in
label.
critical( label : String, button1 : ButtonType, button2 : ButtonType, button3 : ButtonType, title : String ) Displays a critical error message box with the content specified in
label.
.txt.
var filename = FileDialog.getOpenFileName( "*.txt" ); if (filename) { processfile(filename); }
getOpenFileName( filter : String, title : String ); Opens an "Open" dialog. If
filter
is specified (e.g. "textfiles (*.txt)"), only those files which match the filter are shown. The function returns a string with the selected filename, orundefined
if the user canceled.getSaveFileName( filter : String, title : String ); Opens an "Save As" dialog. If
filter
is specified (e.g. "textfiles (*.txt)"), only those files which match the filter are shown. The function returns a string with the filename selected or entered, orundefined
if the user canceled.getExistingDirectory( dir : String, title : String ); Opens a "Find Directory" dialog for the user to select an existing directory. The parameter
dir
can be used to specify the initial directory. Returns the name of the selected directory or undefined if the user canceled.getOpenFileNames( dir : String, filter : String, title : String ); Opens an "Open" dialog for the user to select and open one or more existing files. If
dir
is specified it specifies the initial directory. Iffilter
is specified (e.g. "textfiles (*.txt)"), only those files which match the filter are shown. The function returns a list of string string with the selected filenames, or undefined if the user canceled.
var name = Input.getText( "What is your surname? " ); if (name) { processname(name); }
getText( label : String, text : String, title : String ); Asks the user for a text.
label
specifies the descriptive label andtext
specifies the default text. The function returns the text entred by the user orundefined
if the user canceled.getNumber( label : String, value : Number, decimals : Number, minValue : Number, maxValue : Number, title : String ); Asks the user for a number.
label
specifies the descriptive label,value
specifies the default value,decimals
specifies the number of decimals allowed,minValue
specifies the minimum value andmaxValue
specifies the maximum value. The function returns the value entered by the user orundefined
if the user canceled.getItem( label : String, itemList : Array, current : String, editable : Boolean, title : String ); Asks the user to select an item from a predefined list of values specified by
itemList.
The descriptive label is specified withlabel.
current
specifies the value that is selected when the dialog starts. If editable is true, the user is allowed to enter a value that is not in theitemList.
The function returns the value selected or entered by the user orundefined
if the user canceled.