guideExport to PDF - quick start

This article aims to get you up and running with the Export to PDF feature in your CKEditor Premium Features free trial.

Follow the steps below:

# Subscribe to the CKEditor Premium Features free trial

Create an account by signing up for CKEditor Premium Features free trial. After signing up, you will receive access to the customer dashboard (CKEditor Ecosystem dashboard).

CKEditor Premium Features free trial sign-up view.

You will be asked to check the features you are most interested in.

Checking these features does not affect the trial bundle contents — all the features will be available regardless of the choice. We just want to know your needs better.

# Log in to the CKEditor Ecosystem dashboard

Log in to the CKEditor Ecosystem dashboard. You will receive a confirmation email and will be asked to create a password for your account. Keep it safe.

# Account dashboard

After logging in, click “CKEditor” under the “Your products” header on the left. You will see the subscription parameters overview together with the management area below.

Your CKEditor trials view in the customer dashboard.

# Creating token endpoint

Before you can use your newly activated CKEditor Premium Features free trials bundle, 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 export to PDF, 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 environment to serve separate instances or integrations. From the list of environments choose the one that you want to manage.

    Environments list.

    Please refer to the the environment management guide if needed.

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

    Press the button to generate the development token URL.

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

    CKEditor 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 in production. Anyone knowing this URL will have full access to the associated environment.

# Writing your 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 PDF feature with the editor

# Integrating the Export to PDF feature with CKEditor 5

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):

import ExportPdf from '@ckeditor/ckeditor5-export-pdf/src/exportpdf';

ClassicEditor
     .create( document.querySelector( '#editor' ), {
          plugins: [ ExportPdf, ... ],
          toolbar: [
                'exportPdf', '|',
                ...
          ],
          exportPdf: {
                tokenUrl: 'https://example.com/cs-token-endpoint',
                stylesheets: [
                     './path/to/fonts.css',
                     'EDITOR_STYLES',
                     './path/to/style.css'
                ],
                fileName: 'my-file.pdf',
                converterOptions: {
                     format: 'A4',
                     margin_top: '20mm',
                     margin_bottom: '20mm',
                     margin_right: '12mm',
                     margin_left: '12mm',
                     page_orientation: 'portrait'
                }
          }
     } )
     .then( ... )
     .catch( ... );

Visit the CKEditor 5 export to PDF plugin guide for more details on these configuration options.

# Integrating the Export to PDF feature with CKEditor 4

CKEditor 4 reached its End of Life (EOL) in June 2023, with no future updates, bug fixes, and security patches. Learn how to migrate to CKEditor 5 here.

If you are not ready to migrate yet, we offer an Extended Support Model Package that provides protection against security vulnerabilities and third-party API changes.

Contact our Sales team for more details.

You can use the Online builder for CKEditor 4 to integrate the Export to PDF plugin into your build.

There is just one thing you have to do to activate the plugin — set the exportPdf_tokenUrl configuration option:

CKEDITOR.replace( 'editor', {
    exportPdf_tokenUrl: 'https://example.com/cs-token-endpoint'
} )

This is all. Refer to the Export to PDF configuration guide for a step-by-step integration walk-through.

# Using the REST API service

The WYSIWYG editor plugin is not the only option possible to put the CKEditor Cloud Services HTML to PDF converter service. You can also generate your PDF documents programmatically from HTML data, using the feature’s REST API, as mentioned in the feature overview. It is a convenient and powerful solution if the data needs to be processed between edition and file generation, for example when serializing names, mail merge, etc.

Refer to the Export to PDF guide to get in-depth information about the REST API and check the available options.