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 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
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 HTML to PDF converter service to generate the document-name.pdf
files.
The Export to PDF feature is currently only available exclusively for on-premise
setups, requiring a self-hosted HTML to PDF converter service and the exportpdf_service_url
option to be properly configured. If you require access to this feature, please contact us. Refer to our on-premises documentation for detailed instructions on deploying the Export to PDF service server-side component using Docker.
Update the exportpdf_service_url configuration in your TinyMCE setup to point to your host. For instance, if your host is mycustomhost.com , the URL will be https://mycustomhost.com/v1/convert .
|
Type: String
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 |
---|---|
|
Generates a PDF file directly from the editor. |
These toolbar buttons can be added to the editor using:
-
The
toolbar
configuration option. -
The
quickbars_insert_toolbar
configuration option.
Menu items
The Export to PDF plugin provides the following menu items:
Menu item identifier | Default Menu Location | Description |
---|---|---|
|
Export to PDF |
Generates a PDF file directly from the editor. |
These menu items can be added to the editor using:
-
The
menu
configuration option. -
The
contextmenu
configuration option.
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 |
tinymce.activeEditor.execCommand('ExportPDF');
API Reference
Explore the comprehensive API documentation for the Export to PDF Premium plugin at Export to PDF.