Practical javadocx

Creating a new document

Introduction

Once the javadocx installation is completed, you can work with the library. To begin with, we are going to generate a document from scratch, that is, without external templates.

To do this, you'll create an example as simple as possible in which you'll add a text line and then, save the document with a name of your choice.

Whether it is necessary to create a single document or hundreds of thousands, javadocx simply is the perfect tool.

Create your first DOCX

The full code for creating a document is the following:

First, import CreateDocx:

Then, in your class, create a new document:

You are going to add text, so add a string variable:

... and then add it to the document with the method addText:

To, finally generate the document:

With the file name tutorial_2.docx

Destination path/route

When generating the document with the createDocx method, you can specify a relative or absolute path, to indicate the name and path where the file is going to be saved.

For example:

saves the document in the execution directory.

generates the document in the sub-directory files, located one level above the current directory; or

saves it in the path /var/javadocx/files.

Before setting a path for saving your files, it is necessary to check that the execution user has the required read and write access rights.

Documentation

With each package of javadocx, full documentation comes in javadocx file format, which is the main reference to know in depth the software library. All public methods include a description of each of the available parameters.

In addition, it is advisable to visit:

Other useful resources

For further information and to solve doubts about the use of the library, there are several resources, both internal and external:

  • Contact

    Contact form, for direct communication with the javadocx team

  • Stack Overflow

    Reference forum for developers

Next - Working with templates