guideQuick start

The aim of this article is to get you up and running with the Export to Word service.

Follow the steps below:

  • Subscribe to Export to Word on the CKEditor website.
  • Generate your access credentials in the CKEditor Ecosystem customer dashboard.
  • Configure CKEditor.

All steps are explained in details below.

You can also sign up for the CKEditor Premium Features 30-day free trial if you want to test this feature first.
Please refer to the Premium Features trial guide for more details.

# Subscribe to CKEditor Cloud Services

Create an account in CKEditor Cloud Services by signing up to Export to Word. After signing up, you will receive access to the customer dashboard (CKEditor Ecosystem dashboard).

# Log in to the CKEditor Ecosystem dashboard

Log in to the CKEditor Ecosystem dashboard and navigate to “Your products > CKEditor”.

From the list of available subscriptions in the dashboard choose the Export to Word subscription that you want to manage and press the “Manage” link.

Your dashboard view.

On the next page you will see the subscription parameters overview together with the management area below.

CKEditor with Premium Features trial view.

# Using the service with REST API

The Export to Word service may be used to convert the HTML data into DOCX files. In order to use it, authorization is needed in the form of an authorization token.

The authorization token need to be passed as a value of the Authorization header.

{
    'Authorization': 'Your generated authorization token'
}

# Generating the authorization token

The authorization token can be generated in two ways:

  1. As a value returned from the security token endpoint.
  2. Locally created token.

# Creating access credentials

From the list of environments select the one that you want to manage.

Environments list.

Go to the “Access credentials” tab and click the “Create a new access key” button.

The “Create a new access key” button.

The modal will show up and will prompt for a name for the new access key. Provide the name and click the “Save” button.

Access key name prompt.

The newly created access key will be present on the list of access keys.

Access keys list with hidden key.

The value of the new access key will be hidden. To show the value, click the “Show” button in the “Actions” column.

Access keys list with visible key.

For your safety, the access key value will disappear in a few seconds. You will be able to display it again by clicking the “Show” button. Make sure to keep the access credentials in a safe place.

Read more about dealing with the credentials in the Managing access credentials section of the Environments management guide.

# Example request

Tokens for the HTML to DOCX converter service require passing a payload with a few parameters:

  • aud – The environment ID.
  • iat – “Issued at”. Make sure iat is present and contains correct time. Some JWT implementations do not include it by default.

The accessKey value needs to be replaced with your own access key generated before.

The following example presents a request that contains the required Authorization header for the HTML to DOCX converter:

const jwt = require( 'jsonwebtoken' );
const axios = require( 'axios' );

const accessKey = 'iGC6md5EcTG0DDZqEf4m4eytr679z0Ch2gIQuraBPzyWEtTbcpQAqAhA9LxpkDtpn';

const payload = {
    aud: 'DO3zekDU3LiJX8GOL2xt',
    iat: Date.now(),
}

const token = jwt.sign( payload, accessKey, { algorithm: 'HS256' } );

axios( {
    method: 'post',
    url: 'https://docx-converter.cke-cs.com/docs',
    data: {
  html: "<p>I am a teapot</p>",
  css: "p { color: red; }",
  options: {
    header: [
      {
            html: '<h1>Hi! I\'m header!</h1>',
            css: 'h1 { color: pink; }',
            type: 'first'
      }
    ]
  }
}
    },
    headers: {
        'Authorization': token
    }
} ).then( response => {
    console.log( response );
} ).catch( error => {
    console.log( error );
} );

Please refer to the converter documentation to start using the service.

# Using the Export to Word feature as a plugin

In order to use the export to Word feature in your CKEditor 5 build, a token URL is needed for authorization.

# Creating token endpoint

Before you can use the feature, you first need to create a security token endpoint in your application. The role of this endpoint is to securely authorize end users of your application to use CKEditor Cloud Services only if they should have access to the content or action they are requesting.

# Development token endpoint (fast and easy)

If you are just starting, you may use the development token endpoint URL which is available out of the box and requires no coding on your side. The URL of the development token endpoint can be obtained easily in three simple steps:

  1. To work with CKEditor premium features like real-time collaboration, exports or easy image, you need to create an environment. Environments allow you to create access credentials, manage webhooks, configure features and connect to CKEditor Cloud Services. You may have more than one to serve separate instances or integrations. From the list the environments choose the one that you want to manage.

Environments list.

Please refer to the the environment management guide if needed.

  1. After choosing the environment, press the “Generate” button in the “Development token URL” section of the “CKEditor configuration” tab:

Press the button to generate development token URL.

The development token URL will show up in the “Development token URL” section:

CKEditor 5 Configuration with the development token URL.

The development token endpoint is a special endpoint to help you in getting started with CKEditor Cloud Services. It offers unrestricted, full access to the service and will expire 30 days after being used for the first time. You should not use it on production. Anyone knowing this URL will have full access to the associated environment.

# Writing your own token endpoint (advanced users)

Skip this step if you use the development token endpoint.

To write your own security token endpoint, you need to create access credentials for the selected environment by going to the “Access credentials” tab and clicking the “Create a new access key” button.

Read more in the Creating access credentials section of the Environments management guide.

# Integrating the Export to Word plugin with the application

To install the plugin into your WYSIWYG editor, use the online builder to generate a custom CKEditor 5 build with the plugin enabled. Alternatively, refer to the installation guide in the plugin documentation to do it on your own.

Configure the plugin using the token generated earlier, pasting the link in the configuration (see CloudServicesConfig):

    ClassicEditor
        .create( document.querySelector( '#editor' ), {
            cloudServices: {
                tokenUrl: 'https://example.com/cs-token-endpoint',
            }
        } )
        .then( ... )
        .catch( ... );

This is all. At this point, the export to Word feature will be automatically enabled in your application.

Refer to the CKEditor 5 export to Word guide if you need more information on integrating Export to Word with your WYSIWYG editor!