Export to PDF
Download the document as a PDF with real, selectable text, links and an accessibility tag tree, or as a print-style image of the page.
- PDF with selectable text (
exportpdf/editor.exportToPdf()): written directly in the browser, with no library, canvas or server. Text can be searched and copied, links are clickable, headings, lists, tables and images keep their structure, and the file is tagged so screen readers can read it. - Print-style PDF (
html2pdf): an image of each page, pixel-for-pixel what the editor shows. Use it when the exact look matters more than the text. editor.getPdfBytes()returns the file as bytes, for uploading or attaching instead of downloading.
Example code
<div id="div_editor1"></div>
<button onclick="editor1.exportToPdf('report')">Download PDF (selectable text)</button>
<button onclick="editor1.execCommand('html2pdf')">Print-style PDF (image of the page)</button>
<script>
var config = {};
config.toolbar = "mytoolbar";
config.toolbar_mytoolbar = "{bold,italic,underline}|{paragraphs}|{insertorderedlist,insertunorderedlist}|{inserttable,insertlink}";
config.pdfExportFileName = "report"; // default file name
config.pdfExportFont = "helvetica"; // helvetica | times | courier
var editor1 = new RichTextEditor("#div_editor1", config);
// Or keep the bytes, e.g. to upload them:
// var bytes = editor1.getPdfBytes(); // Uint8Array
</script>