Word Plugin

Works with any OS, supported by Servoy because there is no need for clients to have MS Word® installed.

OVERVIEW

The Word Plugin makes it possible to create a Microsoft Word® document without the need to have Microsoft Word® installed and platform independent. Because there is no need to have Microsoft Word® installed it is possible to generate a document from any Smart, Web, Headless and NG client!

The Word Plugin supports features like document creation, content manipulation and mail merge abilities.
Content manipulation is done, amongst others, by moving to bookmarks and inserting text, images, fonts and other formatting.
It is also possible to insert data bookmark per bookmark or by inserting a dataset, foundset or record.

You can work with several document formats among which:

  •    DOC, DOCM, DOCX etc. MS Word®
  •    PDF Portable Document Format
  •    RTF Rich Text Format
  •    TEXT Text Format
  •    HTML HyperText Markup Language

The document format can be chosen by adding the correct extension or save format.

The included sample solution shows you the how you can create a new blank document or a document based on an existing template/document (included).

Some of the available methods in the Document object are:

  • Document. replaceBookmark – Replace with the entered text (or array of textlines)
  • Document. replaceBookmarks – Replace with the columnnames and row values (arrays), dataset, foundset or record
  • Document. gotoStart – Go to the beginning of the Microsoft Word® document
  • Document. totEnd – Go to the end of the Microsoft Word® document
  • Document. gotoBookmark – Go to the bookmark by name
  • Document. insertDocument – Insert a (Microsoft Word®) document at the selected position
  • Document. insertPagebreak – Insert a pagebreak at the selected position
  • Document. insertImage – Insert an image at the selected position
  • Document. insertText – Insert the entered text (or array of textlines) at the selected position

Some of the available properties in the Document object are:

  • Document. font – Set the font (family, style and size)
  • Document. fontColor – Set a new font color

BENEFITS

  • Generate a native MS Word® document direct from your solution.
  • Use MS Word® templates to generate a new document.
  • Generate mail-merge documents.

In short: every developer that needs standardized documents will benefit.

COMPATIBILITY

Smart client Headless client Web client Mobile client NG client
8.0+ 1.6+
7.0+ 1.6+ n/a
6.1+ 1.6+ n/a n/a

DOCUMENTATION

We published our API Specifications for the Word Plug-in as a future and current reference.

After downloading the Word Plug-in using our Components Manager a sample solution {servoy_root}/solutions/it2be-examples/it2be-word.servoy is installed.
You can import the sample solution into Servoy Developer and you will have some (basic) code examples of how to use the Word Plug-in.

FAQ

Why does my application-server slow down and finally halt when importing a document/template?

There can be many reasons for this behaviour but one of the reasons, reported by Roland Philipp from om computer, was the use of a non-standard quotes.
It might even be caused by other characters that are non-standard.

The problem is that it is not easy to catch them so an exception is not thrown either.

So, when you experience a problem like this, please check for such characters first.
It might save you some time!

I use the Word Plugin in a webclient but need a local copy of the output file.

In the below example I make use of the Tools Plugin to save the file in a ‘safe’ location on the webserver.
But you can of course use your own method for that.

By using the Servoy File Plugin as shown in the code example you can save (download) the resulting byte[] to the browser default ‘downloads’ folder.
This should do the trick!

vOutputFile = vDocument.save(plugins.it2be_tools.server().userHome + "/document.docx");</p>
<p>application.output(vOutputFile, LOGGINGLEVEL.INFO);</p>
<p>vData = plugins.file.readFile(vOutputFile);</p>
<p>vResult = plugins.file.writeFile("document.docx", vData);</p>
<p>application.output(vResult, LOGGINGLEVEL.INFO);
I use the Word v4 Plugin to create a document with charts but the document is not written.

Chances are that you still have a library installed for Java 5. It should work when you remove ~/plugins/it2be-word/aspose-words-jdk15.jar from your (current) Servoy installation.

BUY NOW

Developer

$400

One developer & unlimited deployment

  • +35% p/y
    maintenance fee

Site

$880

Team of developers & unlimited deployment

  • +35% p/y
    maintenance fee