publish
plugins.it2be_word.IWDocument info


Servoy Properties Summary
Object debugMissingBookmarks
String font
String fontColor
Number fontKerning
Number fontSpacing
Boolean removeEmptyParagraphsFromMailmerge
Boolean removeUnusedFieldsFromMailmerge


Servoy Methods Summary
void appendDocument( IWDocument, Number, Boolean )
IWDocument clone( )
IWFormattedDataSet convertDataSet( JSDataSet )
IWTable createTable( Object )
IWTable createTable( Object, Array<Object> )
Array<IWBookmark> getBookmarks( )
Document getDocument( )
Number getFontSize( )
Array<String> getMailMergeFieldNames( )
void gotoBookmark( String )
void gotoEnd( )
void gotoStart( )
void insertAlignment( Number )
void insertBookmark( String, String )
void insertCheckbox( String, Boolean, Number )
void insertDocument( IWDocument )
void insertDocument( IWDocument, Number )
void insertField( String, String )
void insertHtml( String )
void insertImage( Object )
void insertImage( Object, Number, Number )
void insertImage( Object, String, String )
void insertMailMergeField( String, String, String, Number, Number, Number )
void insertPagebreak( )
void insertStyleIdentifier( Number )
void insertTable( IWTable )
void insertTableOfContents( String )
void insertText( String, String, String, Number, Number, Number )
void mailMerge( Object )
void moveToFirstFooter( Number )
void moveToFirstHeader( Number )
void moveToPrimaryFooter( Number )
void moveToPrimaryHeader( Number )
void removeBookmark( String )
void replaceBookmark( String, String )
void replaceBookmarkWithCheckbox( String, String, Boolean, Number )
void replaceBookmarkWithImage( String, Object )
void replaceBookmarkWithPageBreak( String )
void replaceBookmarkWithTable( String, IWTable )
void replaceBookmarks( Object )
void replaceBookmarks( Array<String>, Array<Object> )
void replaceRegEx( String, String )
void replaceText( String, String )
void replaceTextTags( Object, String )
void replaceTextTags( Object )
String save( String, Number )
String save( String, Number, Boolean )
String save( String )
void setAuthor( String )
void setComments( String )
void setCompany( String )
void setDifferentFirstPageHeaderFooter( Boolean )
void setFontAttributes( String, String, Number, Number, )
void setFontFolder( String, Boolean )
void setFontFolders( Array<String>, Boolean )
void setKeywords( String )
void setPaperOrientationLandscape( )
void setPaperOrientationPortrait( )
void setPaperSize( Number )
void setSurpressBlankLinesFromMailmerge( Boolean )
void setTitle( String )
void setVersion( Number )
void updateFields( )


Servoy Properties Details


debugMissingBookmarks
Object  debugMissingBookmarks
Show debugging output for missing bookmarks.
Returns
Object  missing Object

Supported Clients
SmartClient, WebClient, NGClient


font
String  font
Get/Set the textFont for the rest of the document.
Returns
String  String

Supported Clients
SmartClient, WebClient, NGClient

Sample
// Get/Set the textFont for the rest of the document.
// Important: Sample documents are stored in a server folder but your (smart) client needs locally stored documents!

// Sample documents are stored in the application_server/docs folder
var vSamplePath = "../application_server/docs/it2be-word";
if ( application.getOSName( ).indexOf( "Mac" ) > -1 ) {
vSamplePath = "../../../" + vSamplePath;
}

// Create the Word document with the selected original
var vDocument = plugins.it2be_word.openDocument( vSamplePath + "/Bookmarks.dot" );
var vInsertion = plugins.it2be_word.openDocument( vSamplePath + "/Insertion.doc" );

//go to the selected bookmark, insert object and remove bookmark
/** @type {String} */
var text = utils.dateFormat( new Date( ), i18n.getDefaultDateFormat( ) );

vDocument.gotoBookmark( "date" );
vDocument.textFont = "Courier,2,12";
vDocument.fontColor = "#ff0000";
vDocument.insertText( text );
vDocument.removeBookmark( "date" );

vDocument.gotoBookmark( "company_name" );
vDocument.textFont = "Courier,2,12";
vDocument.insertText( "IT2BE" );
vDocument.removeBookmark( "company_name" );

vDocument.gotoBookmark( "fullname" );
vDocument.textFont = "Courier,2,12";
vDocument.insertText( "Marcel Trapman" );
vDocument.removeBookmark( "fullname" );

vDocument.gotoBookmark( "fax_direct" );
vDocument.textFont = "Courier,2,12";
vDocument.insertText( "+31 847 44 36 75" );
vDocument.removeBookmark( "fax_direct" );

vDocument.gotoBookmark( "firstname" );
vDocument.textFont = "Courier,2,12";
vDocument.insertText( "Marcel," );
vDocument.removeBookmark( "firstname" );

vDocument.gotoBookmark( "body" );
vDocument.insertDocument( vInsertion )
vDocument.insertText( "Use the replaceBookmarks(vDataSet) method to replace the bookmarks found in the sample document.

To create bookmarks you should follow the below steps:" );
vDocument.removeBookmark( "body" );

vDocument.removeBookmark( "company_logo" );

vDocument.gotoBookmark( "user" );
vDocument.insertText( "security.getUserName()" );
vDocument.removeBookmark( "user" );

// Define where and under what name you want the save the new file
// the path name should ALWAYS be the complete absolute path
// by adding the extension or the document type you also set the format (default is .docx)
// available formats/extensions are .doc, .docx, .txt and .html
var vDocumentPath = plugins.file.getDesktopFolder( ) + "/it2be-word.docx";
vDocument.save( vDocumentPath );


fontColor
String  fontColor
Get/Set the textFont color for the rest of the document.
Returns
String  String

Supported Clients
SmartClient, WebClient, NGClient

Sample
// Get/Set the textFont color for the rest of the document.
// Important: Sample documents are stored in a server folder but your (smart) client needs locally stored documents!

// Sample documents are stored in the application_server/docs folder
var vSamplePath = "../application_server/docs/it2be-word";
if ( application.getOSName( ).indexOf( "Mac" ) > -1 ) {
vSamplePath = "../../../" + vSamplePath;
}

// Create the Word document with the selected original
var vDocument = plugins.it2be_word.openDocument( vSamplePath + "/Bookmarks.dot" );
var vInsertion = plugins.it2be_word.openDocument( vSamplePath + "/Insertion.doc" );

//go to the selected bookmark, insert object and remove bookmark
/** @type {String} */
var text = utils.dateFormat( new Date( ), i18n.getDefaultDateFormat( ) );

vDocument.gotoBookmark( "date" );
vDocument.textFont = "Courier,2,12";
vDocument.fontColor = "#ff0000";
vDocument.insertText( text );
vDocument.removeBookmark( "date" );

vDocument.gotoBookmark( "company_name" );
vDocument.textFont = "Courier,2,12";
vDocument.insertText( "IT2BE" );
vDocument.removeBookmark( "company_name" );

vDocument.gotoBookmark( "fullname" );
vDocument.textFont = "Courier,2,12";
vDocument.insertText( "Marcel Trapman" );
vDocument.removeBookmark( "fullname" );

vDocument.gotoBookmark( "fax_direct" );
vDocument.textFont = "Courier,2,12";
vDocument.insertText( "+31 847 44 36 75" );
vDocument.removeBookmark( "fax_direct" );

vDocument.gotoBookmark( "firstname" );
vDocument.textFont = "Courier,2,12";
vDocument.insertText( "Marcel," );
vDocument.removeBookmark( "firstname" );

vDocument.gotoBookmark( "body" );
vDocument.insertDocument( vInsertion )
vDocument.insertText( "Use the replaceBookmarks(vDataSet) method to replace the bookmarks found in the sample document.

To create bookmarks you should follow the below steps:" );
vDocument.removeBookmark( "body" );

vDocument.removeBookmark( "company_logo" );

vDocument.gotoBookmark( "user" );
vDocument.insertText( "security.getUserName()" );
vDocument.removeBookmark( "user" );

// Define where and under what name you want the save the new file
// the path name should ALWAYS be the complete absolute path
// by adding the extension or the document type you also set the format (default is .docx)
// available formats/extensions are .doc, .docx, .txt and .html
var vDocumentPath = plugins.file.getDesktopFolder( ) + "/it2be-word.docx";
vDocument.save( vDocumentPath );


fontKerning
Number  fontKerning
Get/Set the textFont kerning for the rest of the document.
Returns
Number  the js _get font kerning

Supported Clients
SmartClient, WebClient, NGClient


fontSpacing
Number  fontSpacing
Get/Set the font spacing
Returns
Number  the js _get font spacing

Supported Clients
SmartClient, WebClient, NGClient


removeEmptyParagraphsFromMailmerge
Boolean  removeEmptyParagraphsFromMailmerge
Specifies whether paragraphs that contained mail merge fields with no data should be removed from the document. When this option is set, paragraphs which contain region start and end merge fields which are otherwise empty are also removed.
Returns
Boolean  remove boolean

Supported Clients
SmartClient, WebClient, NGClient


removeUnusedFieldsFromMailmerge
Boolean  removeUnusedFieldsFromMailmerge
Specifies whether unused merge fields should be removed from the document.
Returns
Boolean  remove boolean

Supported Clients
SmartClient, WebClient, NGClient

Servoy Methods Details


appendDocument
void  appendDocument( IWDocument, Number, Boolean )
Append the document
Parameters
IWDocument  document:IWDocument  the document
Number  importFormatMode:int  the import format mode
Boolean  forceNewPage:boolean  the force new page

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


clone
IWDocument  clone( )
Clone a document
Returns
IWDocument  document IWDocument

Supported Clients
SmartClient, WebClient, NGClient


convertDataSet
IWFormattedDataSet  convertDataSet( JSDataSet )
Convert a JSDataSet to a FormattedDataSet
Parameters
JSDataSet  dataSet  the data set

Returns
IWFormattedDataSet  set IWFormattedDataSet

Supported Clients
SmartClient, WebClient, NGClient


createTable
IWTable  createTable( Object )
Create a table for the document using an Array or a (Formatted) DataSet and an optional custom header array.
Parameters
Object  set  Object[] or JSDataSet or FormattedDataSet

Returns
IWTable  table IWTable

Supported Clients
SmartClient, WebClient, NGClient


createTable
IWTable  createTable( Object, Array<Object> )
Create a table for the document using an Array or a (Formatted) DataSet and an optional custom header array.
Parameters
Object  set  Object[] or JSDataSet or FormattedDataSet
Array<Object>  header  the header

Returns
IWTable  table IWTable

Supported Clients
SmartClient, WebClient, NGClient


getBookmarks
Array<IWBookmark>  getBookmarks( )
Returns an array with all the bookmarks (names and text) available.
Returns
Array<IWBookmark>  bookmarks IWBookmark[]

Supported Clients
SmartClient, WebClient, NGClient

Sample
// Retrieve all bookmarks
var bookmarks = vDocument.getBookmarks();
var bookmark;
var index;

// Loop through your bookmarks
for (index = 0 ; index < bookmarks.length ; index++) {
bookmark = bookmarks[index];

// When using the IWBookmark like this the name (String value) is returned
application.output(bookmark);

// Or use the IWBookmark.getName() and IWBookmark.getText() methods
application.output(bookmark.getName());
application.output(bookmark.getText());


getDocument
Document  getDocument( )
TODO create description
Returns
Document  

Supported Clients
SmartClient, WebClient, NGClient


getFontSize
Number  getFontSize( )
Get/Set the font size
Returns
Number  the js _get font size

Supported Clients
SmartClient, WebClient, NGClient


getMailMergeFieldNames
Array<String>  getMailMergeFieldNames( )
Returns an array with all the mailmerge field names available.
Returns
Array<String>  the js _get mail merge field names

Supported Clients
SmartClient, WebClient, NGClient


gotoBookmark
void  gotoBookmark( String )
Go to the bookmark by name.
Parameters
String  bookmark  the bookmark

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient

Sample
// Go to the bookmark by name.
// Important: Sample documents are stored in a server folder but your (smart) client needs locally stored documents!

// Sample documents are stored in the application_server/docs folder
var vSamplePath = "../application_server/docs/it2be-word";
if ( application.getOSName( ).indexOf( "Mac" ) > -1 ) {
vSamplePath = "../../../" + vSamplePath;
}

// Create the Word document with the selected original
var vDocument = plugins.it2be_word.openDocument( vSamplePath + "/Bookmarks.dot" );
var vInsertion = plugins.it2be_word.openDocument( vSamplePath + "/Insertion.doc" );

//go to the selected bookmark, insert object and remove bookmark
/** @type {String} */
var text = utils.dateFormat( new Date( ), i18n.getDefaultDateFormat( ) );

vDocument.gotoBookmark( "date" );
vDocument.textFont = "Courier,2,12";
vDocument.fontColor = "#ff0000";
vDocument.insertText( text );
vDocument.removeBookmark( "date" );

vDocument.gotoBookmark( "company_name" );
vDocument.textFont = "Courier,2,12";
vDocument.insertText( "IT2BE" );
vDocument.removeBookmark( "company_name" );

vDocument.gotoBookmark( "fullname" );
vDocument.textFont = "Courier,2,12";
vDocument.insertText( "Marcel Trapman" );
vDocument.removeBookmark( "fullname" );

vDocument.gotoBookmark( "fax_direct" );
vDocument.textFont = "Courier,2,12";
vDocument.insertText( "+31 847 44 36 75" );
vDocument.removeBookmark( "fax_direct" );

vDocument.gotoBookmark( "firstname" );
vDocument.textFont = "Courier,2,12";
vDocument.insertText( "Marcel," );
vDocument.removeBookmark( "firstname" );

vDocument.gotoBookmark( "body" );
vDocument.insertDocument( vInsertion )
vDocument.insertText( "Use the replaceBookmarks(vDataSet) method to replace the bookmarks found in the sample document.

To create bookmarks you should follow the below steps:" );
vDocument.removeBookmark( "body" );

vDocument.removeBookmark( "company_logo" );

vDocument.gotoBookmark( "user" );
vDocument.insertText( "security.getUserName()" );
vDocument.removeBookmark( "user" );

// Define where and under what name you want the save the new file
// the path name should ALWAYS be the complete absolute path
// by adding the extension or the document type you also set the format (default is .docx)
// available formats/extensions are .doc, .docx, .txt and .html
var vDocumentPath = plugins.file.getDesktopFolder( ) + "/it2be-word.docx";
vDocument.save( vDocumentPath );


gotoEnd
void  gotoEnd( )
Go to the end of the document.
Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


gotoStart
void  gotoStart( )
Go to the beginning of the document.
Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


insertAlignment
void  insertAlignment( Number )
Insert the alignment for the rest of the document.
Parameters
Number  alignment  the alignment

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


insertBookmark
void  insertBookmark( String, String )
Insert a bookmark at the selected position.
Parameters
String  bookmark  the bookmark
String  text  the text

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


insertCheckbox
void  insertCheckbox( String, Boolean, Number )
Insert a checkbox at the selected position by name, value and size.
Parameters
String  name  the name
Boolean  value  the value
Number  size  the size

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


insertDocument
void  insertDocument( IWDocument )
Insert a Document to the existing document (created with createDocument(.) or openDocument(...)...
Parameters
IWDocument  document  the document

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient

Sample
// Insert a Document to the existing document (created with createDocument(.) or openDocument(...)...
// Important: Sample documents are stored in a server folder but your (smart) client needs locally stored documents!

// Sample documents are stored in the application_server/docs folder
var vSamplePath = "../application_server/docs/it2be-word";
if ( application.getOSName( ).indexOf( "Mac" ) > -1 ) {
vSamplePath = "../../../" + vSamplePath;
}

// Create the Word document with the selected original
var vDocument = plugins.it2be_word.openDocument( vSamplePath + "/Bookmarks.dot" );
var vInsertion = plugins.it2be_word.openDocument( vSamplePath + "/Insertion.doc" );

//go to the selected bookmark, insert object and remove bookmark
/** @type {String} */
var text = utils.dateFormat( new Date( ), i18n.getDefaultDateFormat( ) );

vDocument.gotoBookmark( "date" );
vDocument.textFont = "Courier,2,12";
vDocument.fontColor = "#ff0000";
vDocument.insertText( text );
vDocument.removeBookmark( "date" );

vDocument.gotoBookmark( "company_name" );
vDocument.textFont = "Courier,2,12";
vDocument.insertText( "IT2BE" );
vDocument.removeBookmark( "company_name" );

vDocument.gotoBookmark( "fullname" );
vDocument.textFont = "Courier,2,12";
vDocument.insertText( "Marcel Trapman" );
vDocument.removeBookmark( "fullname" );

vDocument.gotoBookmark( "fax_direct" );
vDocument.textFont = "Courier,2,12";
vDocument.insertText( "+31 847 44 36 75" );
vDocument.removeBookmark( "fax_direct" );

vDocument.gotoBookmark( "firstname" );
vDocument.textFont = "Courier,2,12";
vDocument.insertText( "Marcel," );
vDocument.removeBookmark( "firstname" );

vDocument.gotoBookmark( "body" );
vDocument.insertDocument( vInsertion )
vDocument.insertText( "Use the replaceBookmarks(vDataSet) method to replace the bookmarks found in the sample document.

To create bookmarks you should follow the below steps:" );
vDocument.removeBookmark( "body" );

vDocument.removeBookmark( "company_logo" );

vDocument.gotoBookmark( "user" );
vDocument.insertText( "security.getUserName()" );
vDocument.removeBookmark( "user" );

// Define where and under what name you want the save the new file
// the path name should ALWAYS be the complete absolute path
// by adding the extension or the document type you also set the format (default is .docx)
// available formats/extensions are .doc, .docx, .txt and .html
var vDocumentPath = plugins.file.getDesktopFolder( ) + "/it2be-word.docx";
vDocument.save( vDocumentPath );


insertDocument
void  insertDocument( IWDocument, Number )
Insert a Document to the existing document (created with createDocument(.) or openDocument(...)...
Parameters
IWDocument  document  the document
Number  importFormatMode  the import format mode

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient

Sample
// Insert a Document to the existing document (created with createDocument(.) or openDocument(...)...
// Important: Sample documents are stored in a server folder but your (smart) client needs locally stored documents!

// Sample documents are stored in the application_server/docs folder
var vSamplePath = "../application_server/docs/it2be-word";
if ( application.getOSName( ).indexOf( "Mac" ) > -1 ) {
vSamplePath = "../../../" + vSamplePath;
}

// Create the Word document with the selected original
var vDocument = plugins.it2be_word.openDocument( vSamplePath + "/Bookmarks.dot" );
var vInsertion = plugins.it2be_word.openDocument( vSamplePath + "/Insertion.doc" );

//go to the selected bookmark, insert object and remove bookmark
/** @type {String} */
var text = utils.dateFormat( new Date( ), i18n.getDefaultDateFormat( ) );

vDocument.gotoBookmark( "date" );
vDocument.textFont = "Courier,2,12";
vDocument.fontColor = "#ff0000";
vDocument.insertText( text );
vDocument.removeBookmark( "date" );

vDocument.gotoBookmark( "company_name" );
vDocument.textFont = "Courier,2,12";
vDocument.insertText( "IT2BE" );
vDocument.removeBookmark( "company_name" );

vDocument.gotoBookmark( "fullname" );
vDocument.textFont = "Courier,2,12";
vDocument.insertText( "Marcel Trapman" );
vDocument.removeBookmark( "fullname" );

vDocument.gotoBookmark( "fax_direct" );
vDocument.textFont = "Courier,2,12";
vDocument.insertText( "+31 847 44 36 75" );
vDocument.removeBookmark( "fax_direct" );

vDocument.gotoBookmark( "firstname" );
vDocument.textFont = "Courier,2,12";
vDocument.insertText( "Marcel," );
vDocument.removeBookmark( "firstname" );

vDocument.gotoBookmark( "body" );
vDocument.insertDocument( vInsertion )
vDocument.insertText( "Use the replaceBookmarks(vDataSet) method to replace the bookmarks found in the sample document.

To create bookmarks you should follow the below steps:" );
vDocument.removeBookmark( "body" );

vDocument.removeBookmark( "company_logo" );

vDocument.gotoBookmark( "user" );
vDocument.insertText( "security.getUserName()" );
vDocument.removeBookmark( "user" );

// Define where and under what name you want the save the new file
// the path name should ALWAYS be the complete absolute path
// by adding the extension or the document type you also set the format (default is .docx)
// available formats/extensions are .doc, .docx, .txt and .html
var vDocumentPath = plugins.file.getDesktopFolder( ) + "/it2be-word.docx";
vDocument.save( vDocumentPath );


insertField
void  insertField( String, String )
Insert a field at the selected position.
Parameters
String  fieldCode  the field code
String  fieldValue  the field value

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


insertHtml
void  insertHtml( String )
Insert a html string at the selected position.
Parameters
String  html  the html

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


insertImage
void  insertImage( Object )
Insert an image (by path or media type) at the selected position (optional width and height pixels (int) or percentage (string).
Parameters
Object  image  filePath:String or media:byte[]

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


insertImage
void  insertImage( Object, Number, Number )
Insert an image (by path or media type) at the selected position (optional width and height pixels (int) or percentage (string).
Parameters
Object  image  filePath:String or media:byte[]
Number  width  the width
Number  height  the height

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


insertImage
void  insertImage( Object, String, String )
Insert an image (by path or media type) at the selected position (optional width and height pixels (int) or percentage (string).
Parameters
Object  image  filePath:String or media:byte[]
String  width  the width
String  height  the height

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


insertMailMergeField
void  insertMailMergeField( String, String, String, Number, Number, Number )
Insert a mail merge field at the selected position.
Parameters
String  name:String  the name
String  font:String  the font
String  color:String  the color
Number  kerning:int  the kerning
Number  spacing:int  the spacing
Number  underline:int  the underline

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


insertPagebreak
void  insertPagebreak( )
Insert a pagebreak at the selected position.
Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


insertStyleIdentifier
void  insertStyleIdentifier( Number )
Insert a Style Identifier to set a style for the rest of the document.
Parameters
Number  identifier  the identifier

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


insertTable
void  insertTable( IWTable )
Insert a table at the selected position.
Parameters
IWTable  table  the table

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


insertTableOfContents
void  insertTableOfContents( String )
Inserts a TOC (table of contents) field into the document.
Parameters
String  switches  the switches

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient

Sample
// This method inserts a TOC (table of contents) field into the document at
// the current position.
// A table of contents in a Word document can be built in a number of ways
// and formatted using a variety of options. The way the table is built and
// displayed by Microsoft Word is controlled by the field switches.
// The easiest way to specify the switches is to insert and configure a table of
// contents into a Word document using the Insert->Reference->Index and Tables menu,
// then switch display of field codes on to see the switches. You can press Alt+F9 in
// Microsoft Word to toggle display of field codes on or off.
// If you insert a table of contents using this method and then open the file
// in Microsoft Word, you will not see the table of contents because the TOC field
// has not yet been updated.
// In Microsoft Word, fields are not automatically updated when a document is opened,
// but you can update fields in a document at any time by pressing F9.


insertText
void  insertText( String, String, String, Number, Number, Number )
Insert text at the selected position.
Parameters
String  text:String  or Object[]
String  font:String  the font
String  color:String  the color
Number  kerning:int  the kerning
Number  spacing:int  the spacing
Number  underline:int  the underline

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


mailMerge
void  mailMerge( Object )
Mailmerge the document with a Dataset or Foundset.
Parameters
Object  set  JSFoundSet or JSDataSet or FormattedDataSet

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient

Sample
// Mailmerge the document with a Dataset or Foundset.
// Important: Sample documents are stored in a server folder but your (smart) client needs locally stored documents!

// Create a dataset
var vQuery = "SELECT * FROM it2be_companies c, it2be_contacts o WHERE c.it2be_companiesid=o.it2be_companiesid";
var vDataSet = databaseManager.getDataSetByQuery( databaseManager.getDataSourceServerName( controller.getDataSource( ) ), vQuery, null, -1 );

// Stop executing this method when the record is empty and show an error dialog
if ( !vDataSet || vDataSet.getMaxRowIndex( ) == 0 ) {
plugins.dialogs.showErrorDialog( "Error.", "There are no records!", "OK" );
Return;
}

// Sample documents are stored in the application_server/docs folder
var vSamplePath = "../application_server/docs/it2be-word";
if ( application.getOSName( ).indexOf( "Mac" ) > -1 ) {
vSamplePath = "../../../" + vSamplePath;
}

// Define the path to the original
// The path name should ALWAYS be the complete absolute path
var vOriginal = vSamplePath + "/Mailmerge.dot";

// Create the Word document with the selected original
// When you use images you need to set the field type to Image (prefix the name with 'Image:')
var vDocument = plugins.it2be_word.openDocument( vOriginal );

// Replace the 'generic' bookmarks
/** @type {String} */
var text = utils.dateFormat( new Date( ), i18n.getDefaultDateFormat( ) );

vDocument.replaceBookmark( "body", "This is a mail merge sample.

There is nothing more to it than creating a template with merge-fields:" );
vDocument.replaceBookmark( "date", text );
vDocument.replaceBookmark( "user", "security.getUserName()" );

// Mailmerge the document with a foundset or dataset
vDocument.mailMerge( vDataSet );

// Define where and under what name you want the save the new file
// the path name should ALWAYS be the complete absolute path
// by adding the extension or the document type you also set the format (default is .docx)
// available formats/extensions are .doc, .docx, .txt and .html
var vDocumentPath = plugins.file.getDesktopFolder( ) + "/it2be-word.docx";
vDocument.save( vDocumentPath );


moveToFirstFooter
void  moveToFirstFooter( Number )
Create a footer for the first page after moving.
Parameters
Number  distance:int  the distance

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


moveToFirstHeader
void  moveToFirstHeader( Number )
Create a header for the first page after moving.
Parameters
Number  distance:int  the distance

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


moveToPrimaryFooter
void  moveToPrimaryFooter( Number )
Create a footer for all pages after moving.
Parameters
Number  distance:int  the distance

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


moveToPrimaryHeader
void  moveToPrimaryHeader( Number )
Create a header for all pages after moving.
Parameters
Number  distance:int  the distance

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


removeBookmark
void  removeBookmark( String )
Remove the bookmark by name.
Parameters
String  bookmark  the bookmark

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


replaceBookmark
void  replaceBookmark( String, String )
Replace the named bookmark with the entered text.
Parameters
String  bookmark  the bookmark
String  text  the text

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient

Sample
// Replace the named bookmark with the entered text.
// Important: Sample documents are stored in a server folder but your (smart) client needs locally stored documents!

// Sample documents are stored in the application_server/docs folder
var vSamplePath = "../application_server/docs/it2be-word";
if ( application.getOSName( ).indexOf( "Mac" ) > -1 ) {
vSamplePath = "../../../" + vSamplePath;
}

// Define the path to the original
// The path name should ALWAYS be the complete absolute path
var vOriginal = vSamplePath + "/Bookmarks.dot";

// Create the Word document with the selected original
var vDocument = plugins.it2be_word.openDocument( vOriginal );

// When you want to be notified (in the log file) of missing bookmarks
// you should set the debugMissingBookmarks property
// IMPORTANT always place the method BEFORE processing your bookmarks
vDocument.debugMissingBookmarks = true;

// Insert the values at the selected bookmarks
vDocument.replaceBookmark( "company_name", "IT2Be" );
vDocument.replaceBookmark( "fullname", "Marcel Trapman" );
vDocument.replaceBookmark( "fax_direct", "+49 2822 97 58 37" );
vDocument.replaceBookmark( "firstname", "Marcel" );
vDocument.replaceBookmark( "body", "When you want to create a document to use the replaceBookmark method, like we do in this sample document,
you should follow the below steps:" );

/** @type {String} */
var text = utils.dateFormat( new Date( ), i18n.getDefaultDateFormat( ) );

vDocument.replaceBookmark( "date", text );

// Replacing bookmarks in headers and footers is no different
vDocument.replaceBookmark( "user", "security.getUserName()" );

// To replace a bookmark with an image you need to follow a 'detour'
vDocument.gotoBookmark( "company_logo" );
vDocument.insertImage( "media:///logo_it2be.png" );
vDocument.removeBookmark( "company_logo" );

// Define where and under what name you want the save the new file
// the path name should ALWAYS be the complete absolute path
// by adding the extension or the document type you also set the format (default is .docx)
// available formats/extensions are .doc, .docx, .txt and .html
vDocument.save( plugins.file.getDesktopFolder( ) + "/it2be-word.docx" );


replaceBookmarkWithCheckbox
void  replaceBookmarkWithCheckbox( String, String, Boolean, Number )
Replace the named bookmark with a checkbox by name, value and size.
Parameters
String  bookmark  the bookmark
String  name  the name
Boolean  value  the value
Number  size  the size

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


replaceBookmarkWithImage
void  replaceBookmarkWithImage( String, Object )
Replace the named bookmark with an image.
Parameters
String  bookmark  the bookmark
Object  image  filePath:String or media:byte[]

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


replaceBookmarkWithPageBreak
void  replaceBookmarkWithPageBreak( String )
Replace the named bookmark with a page break.
Parameters
String  bookmark  the bookmark

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


replaceBookmarkWithTable
void  replaceBookmarkWithTable( String, IWTable )
Replace the named bookmark with a table.
Parameters
String  bookmark  the bookmark
IWTable  table  the table

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


replaceBookmarks
void  replaceBookmarks( Object )
Replace the bookmarks with the columnnames and row values (arrays), dataset, foundset or record.
Parameters
Object  set  Object[] or JSRecord or JSFoundSet or JSDataSet

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient

Sample
// Replace the named bookmark with the entered text.
// Important: Sample documents are stored in a server folder but your (smart) client needs locally stored documents!

// Sample documents are stored in the application_server/docs folder
var vSamplePath = "../application_server/docs/it2be-word";
if ( application.getOSName( ).indexOf( "Mac" ) > -1 ) {
vSamplePath = "../../../" + vSamplePath;
}

// Define the path to the original
// The path name should ALWAYS be the complete absolute path
var vOriginal = vSamplePath + "/Bookmarks.dot";

// Create the Word document with the selected original
var vDocument = plugins.it2be_word.openDocument( vOriginal );

// When you want to be notified (in the log file) of missing bookmarks
// you should set the debugMissingBookmarks property
// IMPORTANT always place the method BEFORE processing your bookmarks
vDocument.debugMissingBookmarks = true;

// Insert the values at the selected bookmarks
vDocument.replaceBookmark( "company_name", "IT2Be" );
vDocument.replaceBookmark( "fullname", "Marcel Trapman" );
vDocument.replaceBookmark( "fax_direct", "+49 2822 97 58 37" );
vDocument.replaceBookmark( "firstname", "Marcel" );
vDocument.replaceBookmark( "body", "When you want to create a document to use the replaceBookmark method, like we do in this sample document,
you should follow the below steps:" );

/** @type {String} */
var text = utils.dateFormat( new Date( ), i18n.getDefaultDateFormat( ) );

vDocument.replaceBookmark( "date", text );

// Replacing bookmarks in headers and footers is no different
vDocument.replaceBookmark( "user", "security.getUserName()" );

// To replace a bookmark with an image you need to follow a 'detour'
vDocument.gotoBookmark( "company_logo" );
vDocument.insertImage( "media:///logo_it2be.png" );
vDocument.removeBookmark( "company_logo" );

// Define where and under what name you want the save the new file
// the path name should ALWAYS be the complete absolute path
// by adding the extension or the document type you also set the format (default is .docx)
// available formats/extensions are .doc, .docx, .txt and .html
vDocument.save( plugins.file.getDesktopFolder( ) + "/it2be-word.docx" );


replaceBookmarks
void  replaceBookmarks( Array<String>, Array<Object> )
Replace the bookmarks with the columnnames and row values (arrays), dataset, foundset or record.
Parameters
Array<String>  bookmarks  the bookmark names
Array<Object>  set  the values

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient

Sample
// Replace the named bookmark with the entered text.
// Important: Sample documents are stored in a server folder but your (smart) client needs locally stored documents!

// Sample documents are stored in the application_server/docs folder
var vSamplePath = "../application_server/docs/it2be-word";
if ( application.getOSName( ).indexOf( "Mac" ) > -1 ) {
vSamplePath = "../../../" + vSamplePath;
}

// Define the path to the original
// The path name should ALWAYS be the complete absolute path
var vOriginal = vSamplePath + "/Bookmarks.dot";

// Create the Word document with the selected original
var vDocument = plugins.it2be_word.openDocument( vOriginal );

// When you want to be notified (in the log file) of missing bookmarks
// you should set the debugMissingBookmarks property
// IMPORTANT always place the method BEFORE processing your bookmarks
vDocument.debugMissingBookmarks = true;

// Insert the values at the selected bookmarks
vDocument.replaceBookmark( "company_name", "IT2Be" );
vDocument.replaceBookmark( "fullname", "Marcel Trapman" );
vDocument.replaceBookmark( "fax_direct", "+49 2822 97 58 37" );
vDocument.replaceBookmark( "firstname", "Marcel" );
vDocument.replaceBookmark( "body", "When you want to create a document to use the replaceBookmark method, like we do in this sample document,
you should follow the below steps:" );

/** @type {String} */
var text = utils.dateFormat( new Date( ), i18n.getDefaultDateFormat( ) );

vDocument.replaceBookmark( "date", text );

// Replacing bookmarks in headers and footers is no different
vDocument.replaceBookmark( "user", "security.getUserName()" );

// To replace a bookmark with an image you need to follow a 'detour'
vDocument.gotoBookmark( "company_logo" );
vDocument.insertImage( "media:///logo_it2be.png" );
vDocument.removeBookmark( "company_logo" );

// Define where and under what name you want the save the new file
// the path name should ALWAYS be the complete absolute path
// by adding the extension or the document type you also set the format (default is .docx)
// available formats/extensions are .doc, .docx, .txt and .html
vDocument.save( plugins.file.getDesktopFolder( ) + "/it2be-word.docx" );


replaceRegEx
void  replaceRegEx( String, String )
Replace a given regular expression with a new string value.
Parameters
String  regEx  the regex
String  value  the value

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


replaceText
void  replaceText( String, String )
Replace a given string with a new string value.
Parameters
String  oldValue  the old text
String  newValue  the new text

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


replaceTextTags
void  replaceTextTags( Object, String )
Replace a given tag with a a new value (tags should be the same as field names).
Parameters
Object  set  JSRecord or JSFoundSet or JSDataSet
String  tag  the enclosing tag

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


replaceTextTags
void  replaceTextTags( Object )
Replace a given tag with a a new value (tags should be the same as field names).
Parameters
Object  set  JSRecord or JSFoundSet or JSDataSet

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


save
String  save( String, Number )
Save the document with the entered name and optionally close MS Word.
Parameters
String  filePath  the file path
Number  formatType  the document type

Returns
String  fileName String

Supported Clients
SmartClient, WebClient, NGClient


save
String  save( String, Number, Boolean )
Save the document with the entered name and optionally close MS Word.
Parameters
String  filePath  the file path
Number  formatType  the document type
Boolean  overwriteExtension  the overwrite extension

Returns
String  fileName String

Supported Clients
SmartClient, WebClient, NGClient


save
String  save( String )
Save the document with the entered name and optionally close MS Word.
Parameters
String  filePath  the file path

Returns
String  fileName String

Supported Clients
SmartClient, WebClient, NGClient


setAuthor
void  setAuthor( String )
Set author property of the document.
Parameters
String  author  the author

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


setComments
void  setComments( String )
Set comments property of the document.
Parameters
String  comments  the comments

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


setCompany
void  setCompany( String )
Set company property of the document.
Parameters
String  company  the company

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


setDifferentFirstPageHeaderFooter
void  setDifferentFirstPageHeaderFooter( Boolean )
Tell the document to use a different header and footer on the first page.
Parameters
Boolean  value  the value

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


setFontAttributes
void  setFontAttributes( String, String, Number, Number, )
Get/Set the textFont attributes for the rest of the document.

setFontFolder
void  setFontFolder( String, Boolean )
Set textFont folder (will override default textFont folder(s)).
Parameters
String  filePath  the file path
Boolean  recursive  the recursive

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


setFontFolders
void  setFontFolders( Array<String>, Boolean )
Set textFont folders (will override default textFont folder(s)).
Parameters
Array<String>  filePaths  the file paths
Boolean  recursive  the recursive

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


setKeywords
void  setKeywords( String )
Set keywords property of the document.
Parameters
String  keywords  the keywords

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


setPaperOrientationLandscape
void  setPaperOrientationLandscape( )
Set paper orientation to landscape
Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


setPaperOrientationPortrait
void  setPaperOrientationPortrait( )
Set paper orientation to portrait
Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


setPaperSize
void  setPaperSize( Number )
Set the paper size of the document.
Parameters
Number  size  the size

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


setSurpressBlankLinesFromMailmerge
void  setSurpressBlankLinesFromMailmerge( Boolean )
Specifies how the mail merge handles blank lines in the merged documents resulting from the mail merge (default = true).
Parameters
Boolean  surpress  the surpress

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


setTitle
void  setTitle( String )
Set title property of the document.
Parameters
String  title  the title

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


setVersion
void  setVersion( Number )
Set version property of the document.
Parameters
Number  version  the version

Returns
void  

Supported Clients
SmartClient, WebClient, NGClient


updateFields
void  updateFields( )
Use the method to update the TOC (table of contents).
Returns
void  

Supported Clients
SmartClient, WebClient, NGClient