---
title: "Export to PDF plugin"
description: "The Export to PDF feature provides the ability to generate a PDF file directly from the editor."
canonical_url: "https://www.tiny.cloud/docs/tinymce/latest/exportpdf/"
md_url: "https://www.tiny.cloud/docs/tinymce/7/exportpdf/index.md"
version: "7"
last_updated: "2026-05-24T22:44:41Z"
tokens: 2408
---
Important This page documents TinyMCE 7. For new projects, Tiny recommends using the latest, most up-to-date version. [See TinyMCE 8 documentation](../../latest/exportpdf/).
# Export to PDF plugin

> **Note:** This plugin is only available as a [paid add-on](/tinymce/features/export-pdf/) to [a TinyMCE subscription](/pricing).

> **Note:** This feature is only available for TinyMCE 7.0 and later.
The Export to PDF feature collects the HTML generated with the `tinymce.editor.getContent()` method and combines it with the default editor content styles along with the styles provided in the plugin configuration. The combined content and styles are then processed by the included server-side converter service, which can be either self-hosted or cloud-based. Following this processing, a PDF file is generated, which is subsequently returned to the user’s browser, enabling them to save it onto their disk or drive.

## Interactive example

**Example**

```js
tinymce.init({
  selector: 'textarea#exportpdf',
  height: '800px',
  plugins: [
    "exportpdf", "advlist", "anchor", "autolink", "charmap", "code", "codesample", "fullscreen",
    "help", "image", "insertdatetime", "link", "lists", "media",
    "preview", "searchreplace", "table", "visualblocks",
  ],
  toolbar: "undo redo | exportpdf | styles | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
  image_caption: true,
  exportpdf_converter_options: {
    format: 'A4',
    margin_top: '1in',
    margin_right: '1in',
    margin_bottom: '1in',
    margin_left: '1in'
  }
});
```

## Basic setup using the Tiny Cloud service

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

Example:
```js
tinymce.init({
  selector: 'textarea',
  plugins: 'exportpdf',
  toolbar: 'exportpdf',
  // Required for the cloud-based Export to PDF plugin with Tiny Cloud
  // Create a JWT key in the Customer Portal for trial functionality to enable watermark-free exports during the trial period
  exportpdf_token_provider: () => {
    return fetch('http://localhost:3000/jwt', { // specify your token endpoint
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
    }).then(response => response.json());
  },
});
```
For more infomation on the exportpdf_token_provider option, see [exportpdf_token_provider](#exportpdf-token-provider).

> **Important:** The Export to PDF plugin **requires** JWT authentication when using the Tiny Cloud service.
> 
> **Authentication Setup:**
> 
> 1. Create a JWT key in the Customer Portal
> 2. Configure the `exportpdf_token_provider` option to specify the endpoint for retrieving your JWT token
> For more information on how to set up JWT authentication with Export to PDF, see examples: [Export to PDF with JWT authentication (Node.js)](../export-to-pdf-with-jwt-authentication-nodejs/) or [Export to PDF with JWT authentication (PHP)](../export-to-pdf-with-jwt-authentication-php/)
> 
> **Trial period behavior**
> 
> - **Trial Period:**
> 
> - With JWT: Full functionality, unlimited usage, no watermarks.
> - Without JWT: Full functionality with watermarks.
> - **After Trial:**
> 
> - With Export to PDF add-on + JWT: Full functionality (subscription-based)
> - Without add-on: Plugin entitlements are `disabled` and functionality is no longer available.
> Visit the [account portal](/auth/login/) to obtain your JWT key and test full functionality.

## Basic setup using the self-hosted service

To use the self-hosted version of the Export to PDF plugin, you need to set the `exportpdf_service_url` option to the URL of the service.

Example:
```js
tinymce.init({
  selector: 'textarea',
  plugins: 'exportpdf',
  toolbar: 'exportpdf',
  exportpdf_service_url: 'http://localhost:8080/' // Update with the URL of the service you are using such  as 'http://myserver.com/'
});
```

> **Important:** The `exportpdf_service_url` option automatically appends `/v1/convert` to the URL provided, so only the base URL is required. For example, if the service is hosted at `http://localhost:8080/v1/convert`, the `exportpdf_service_url` option should be set to `http://localhost:8080/`. When using in production, ensure that `exportpdf_service_url` is updated to the production URL such as `https://myserver.com/`.

## Options

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

### `exportpdf_service_url`

The Export to PDF plugin uses an HTML-to-PDF converter service to generate `document-name.pdf` files.

This option is **required** when configuring the Export to PDF plugin for `on-premise` setups. If you require access to this feature, please [contact us](/contact/). For detailed instructions on deploying the Export to PDF service server-side component using Docker, refer to the [on-premises documentation](../individual-export-to-pdf-on-premises/).

> **Tip:** When using a custom host, set the `exportpdf_service_url` option in your TinyMCE configuration to match your host. For example, if your custom host is `mycustomhost.com`, set the URL to `https://mycustomhost.com/`.
**Type:** `String`

#### Example: Setting up `exportpdf_service_url`

```js
tinymce.init({
  selector: 'textarea',
  plugins: 'exportpdf',
  toolbar: 'exportpdf',
  exportpdf_service_url: '<service_url>' // required for On-premise setups only
});
```

### `exportpdf_token_provider`

The `exportpdf_token_provider` option enables integration with a token-based authentication service for exporting PDF documents. It provides a mechanism to fetch an authentication token from a specified endpoint. This ensures that the export process can securely communicate with the server.

**Type:** `Function`

**Default value:** `undefined`

**Return data:** [`Token` object](#data-structure)

#### Example: using `exportpdf_token_provider`

```js
tinymce.init({
  selector: 'textarea',
  plugins: 'exportpdf',
  toolbar: 'exportpdf',
  exportpdf_token_provider: () => { // required when using the Export to PDF plugin with Tiny Cloud.
    return fetch('http://localhost:3000/jwt', { // specify your token endpoint
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
    }).then(response => response.json());
  },
});
```

#### Data structure for the JWT token

The object containing the valid encoded token must match the following structure:

```js
{
  token: "<encoded JWT string>"
}
```

| Field | Type | Required? | Description |
| --- | --- | --- | --- |
| `token` | `string` | required | A Base64-encoded JSON Web Token (JWT) used for authentication and authorization. |

### `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`

> **Note:** As of TinyMCE 7.5.0, the `exportpdf_converter_options` setting now comes with a default value set to the following:
**Default value:**
```js
{
  format: 'Letter',
  margin_top: '1in',
  margin_right: '1in',
  margin_bottom: '1in',
  margin_left: '1in'
}
```

#### Example: using `exportpdf_converter_options`

```js
tinymce.init({
  selector: 'textarea',
  plugins: 'exportpdf',
  toolbar: 'exportpdf',
  exportpdf_service_url: '<service_url>', // required if using On-premises service
  exportpdf_converter_options: {
   	header_html: '<p>HEADER</p>', // example
   	header_and_footer_css: 'p { color: blue }', // example
  },
})
```

> **Note:** 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](https://exportpdf.api.tiny.cloud/v1/convert/docs) 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`

```js
tinymce.init({
  selector: 'textarea.tinymce',
  plugins: 'exportpdf',
  toolbar: 'exportpdf',
  exportpdf_service_url: '<service_URL>', // required if using On-premises service
  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 [`toolbar`](../toolbar-configuration-options/#toolbar) configuration option.
- The [`quickbars_insert_toolbar`](../quickbars/#quickbars_insert_toolbar) configuration option.
- [Custom Context toolbars](../contexttoolbar/).

## Menu items

The Export to PDF plugin provides the following menu items:

| Menu item identifier | [Default Menu Location](../menus-configuration-options/#example-the-tinymce-default-menu-items) | Description |
| --- | --- | --- |
| `exportpdf` | Export to PDF | Generates a PDF file directly from the editor. |

These menu items can be added to the editor using:

- The [`menu`](../menus-configuration-options/#menu) configuration option.
- The [`contextmenu`](../menus-configuration-options/#contextmenu) configuration option.
- [Custom Menu toolbar buttons](../custom-menu-toolbar-button/).

## 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
```js
tinymce.activeEditor.execCommand('ExportPDF');
```

## API Reference

> Explore the comprehensive API documentation for the Export to PDF Premium plugin at [Export to PDF API Reference Documentation.](https://exportpdf.api.tiny.cloud/v1/convert/docs)
