Export to PDF - overview
CKEditor Cloud Services offer a fast and highly scalable service enabling the user to export documents to PDF document. The feature is available as a service, making it possible to send an HTML string straight into the Cloud Services server for more advanced use or as convenient WYSIWYG editor plugins for the ease of use in less demanding cases.
If this feature is used without authentication, the resulting document will be watermarked.
# Pagination feature
The complementary premium pagination feature for CKEditor 5 allows you to see where page breaks would be after the document is exported to PDF. Thanks to the live preview, the user is able to fine-tune the structure of the output document when editing it. In addition to this, the pagination feature shows you the page count and allows to easily navigate between the document pages.
# How the Export to PDF feature works
The HTML to PDF converter provides an API for converting HTML documents to PDF files. The service generates a file and returns it to the user so they can save it in the
# The HTML to PDF converter options
The following options are available, while using the converter service:
At least one of
options.footer_html parameters is required to generate a PDF.
Any of these parameters cannot contain the
<meta> tag with the refresh document interval.
If you want to use this API directly, you need to provide proper CSS code manually. To achieve this, you should pass a string which is a concatenation of the default editor styles (e.g. using CKEditor 5’s list of all content styles) and, optionally, your custom styles to the
css property. With the default editor configuration, you do not need to specify the
HTML compliant content can be sent to the converter.
The API only accepts documents with UTF-8 encoded content for conversion.
- All HTML documents use the
<!DOCTYPE html>declaration to generate PDF files.
- The recommended way to generate a PDF document is to send only the HTML content. However, if your document requires a full HTML structure to render properly, you can use it.
This option is used to send custom CSS styles.
Just like the HTML, CSS must be encoded with UTF-8.
If you cannot use UTF-8 and would like to request support for other charsets, please contact us.
The PDF options make it possible to set a header, footer, margins and page format of the output file. There is also the
wait_time parameter to control the render time.
Refer to the converter documentation for details on the syntax and usage of these options.
Images can be either inserted from a URL or Base64-encoded, using the
src attribute of the
# Web Fonts
To generate PDF documents, you can use web fonts like in a regular browser. You need to specify the URL to the font file or a font file converted to the Base64 format.
Refer to the converter documentation for details and examples.
# The Export to PDF editor plugin
The Export to PDF CKEditor plugin allows you to easily print the WYSIWYG editor content to a PDF file. When enabled, this feature sends the content of your editor together with the styles that are used to display it to the CKEditor Cloud Services HTML to PDF converter service. The service then generates a PDF document that can be downloaded by the user.
Thanks to this plugin, it takes exactly one button click to get a PDF file with content formatted in the same way as the one visible in CKEditor WYSIWYG editor. An easy solution for integrations, that do not demand editor data to be processed further once it is edited.