RichTextEditor Demo
Home Pricing

### Dynamic PDF Creation

This example demonstrates you can use Rich Text Editor to create industry standard PDF files on the fly. In the following example, we create a 0x0 size editor which will be used to convert Html to PDF.

### Demo Code:

    import { createRichTextEditor } from "ts-rich-text-editor";

    const editor = await createRichTextEditor("#div_editor1", {}, {
      basePath: "/richtexteditor",
    });

    // Set HTML and export as PDF
    editor.instance.setHTMLCode("<p>Hello World</p>");
    editor.exec("html2pdf");

    <link rel="stylesheet" href="/richtexteditor/rte_theme_default.css" />
    <script type="text/javascript" src="/richtexteditor/rte.js"></script>
    <script type="text/javascript" src='/richtexteditor/plugins/all_plugins.js'></script>
    <div id="div_editor1" style="min-width:0; min-height:0; max-width:0; max-height:0; overflow: hidden;"></div>
    <button class="btn btn-sm btn-primary transition-3d-hover" onclick="downloadPDFDialog()">
    	Check the PDF file
    </button>

    <script>
    	var editor1cfg = {}
    	var editor1 = new RichTextEditor("#div_editor1", editor1cfg);

    	function downloadPDFDialog() {
    		editor1.setHTMLCode("<p>Hello World</p>")
    		editor1.execCommand("html2pdf");
    	}

    </script>