close messageThis website uses 'cookies', both our own as well as from third parties, to provide a better experience and service. When browsing our website or using our services you agree to our use of 'cookies'. For more information, see our Privacy policy.

Cookbook

Integrate javadocx with Drupal 7

Drupal 7 uses the directory sites/all/libraries for external libraries. The easiest integration of javadocx is to copy all the library files in the sites/all/libraries/javadocx and install the libraries module ( https://www.drupal.org/project/libraries).

To run javadocx, just include the library in any content or file that may execute Java and work with the available public methods:

x
 
1
if (file_exists(libraries_get_path('javadocx') . '/classes/CreateDocx.php')) {
2
    require_once libraries_get_path('javadocx') . '/classes/CreateDocx.php';
3
    $docx = new CreateDocx();
4
    $docx->embedHTML('<p>This is a simple sample.</p>');
5
    $docx->createDocx(drupal_realpath('public://') . '/uploads/document.docx');
6
}
7

Although quite simple to do, this integration is not the most advisable, as it requires to include the library when you need it. It is much better to create a module that lets you work with the library with a precise end.

The packages of the Advanced and Premium licenses come with a specific plugin for Drupal 7. This plugin allows to easily export all Drupal nodes to DOCX, converting the HTML of the nodes content, as well as working as a base to generate other plugins.

­
­