Export to PDF plugin

This plugin is only available as a paid add-on to a TinyMCE subscription.
This feature is only available for TinyMCE 7.0 and later.

The Export to PDF functionality gathers the HTML produced using the editor.getcontent() method and the default editor content styles, along with the styles specified in the configuration options for the plugin. This data is transmitted to the TinyMCE Cloud Services HTML to PDF converter service. The service processes this information to create a PDF file, which is then sent back to the user’s browser for saving to their local disk.

Interactive example

Export to PDF demo

Demos containing the Export to PDF plugin are currently only available on our main website. Check out the Export to PDF demo, or the demo on our home page, to try it out today.

Basic setup

To add the Export to PDF plugin to the editor, add exportpdf to the plugins option in the editor configuration.

For example:

tinymce.init({
  selector: 'textarea',
  plugins: 'exportpdf',
  toolbar: 'exportpdf',
  exportpdf_service_url: '<service url>'
});

Options

The following configuration options affect the behavior of the Export to PDF plugin.

exportpdf_service_url

The Export to PDF uses the TinyMCE Cloud Services HTML to PDF converter service to generate the document-name.pdf files.

The Export to PDF feature is currently only available on-premise and requires the exportpdf_service_url option to be configured. Contact us if you require this feature.

Type: String

Example: using exportpdf_service_url

tinymce.init({
  selector: 'textarea',
  plugins: 'exportpdf',
  toolbar: 'exportpdf',
  exportpdf_service_url: '<service_url>'
});

exportpdf_converter_options

This option allows the editor to download a PDF document containing its content, along with the specified options defined in the exportpdf_converter_options.

Type: Object

Default value: {}

Example: using exportpdf_converter_options

tinymce.init({
  selector: 'textarea',
  plugins: 'exportpdf',
  toolbar: 'exportpdf',
  exportpdf_service_url: '<service_url>',
  exportpdf_converter_options: {
   	header_html: '<p>HEADER</p>', // example
   	header_and_footer_css: 'p { color: blue }', // example
  },
})
The exportpdf_service_url option must be configured for the Export to PDF plugin to work.

For comprehensive details regarding the exportpdf_converter_options, please refer to the API documentation available for the Export to PDF Premium plugin.

exportpdf_converter_style

The exportpdf_converter_style option allow for customization of the styles applied to the exported PDF document, providing flexibility in controlling its appearance.

Type: String

Default value: ''

Example: using exportpdf_converter_style

tinymce.init({
  selector: 'textarea.tinymce',
  plugins: 'exportpdf',
  toolbar: 'exportpdf',
  exportpdf_service_url: '<service_URL>', // required
  exportpdf_converter_options: { // required to support "exportpdf_converter_style"
    header: [
      {
        html: '<h1>First page header.</h1>', //example
        css: 'h1 { font-size: 30px; }', //example
      }
    ],
  },
  exportpdf_converter_style: 'p { color: cyan !important }' // requires both "exportpdf_converter_style" and "exportpdf_service_url" to be set.
});

Toolbar buttons

The Export to PDF plugin provides the following toolbar buttons:

Toolbar button identifier Description

exportpdf

Generates a PDF file directly from the editor.

These toolbar buttons can be added to the editor using:

The Export to PDF plugin provides the following menu items:

Menu item identifier Default Menu Location Description

exportpdf

Export to PDF

Generates a PDF file directly from the editor.

These menu items can be added to the editor using:

Commands

The Export to PDF plugin provides the following TinyMCE commands.

Command Description

ExportPDF

Generates a PDF file directly from the editor with the filename document.pdf.

Example
tinymce.activeEditor.execCommand('ExportPDF');

API Reference

Explore the comprehensive API documentation for the Export to PDF Premium plugin at Export to PDF.