0

I am building a custom text editor using vanilla JavaScript, and I need to implement functionality to export the content from the editor into an RTF (Rich Text Format) file.

The basic structure of my editor is as follows:

    <div class="page">
        <div class="header">
            <!-- Header content -->
        </div>
        <div class="body">
            <div class="body-editor">
                <!-- Editable content goes here -->
            </div>
        </div>
        <div class="footer">
            <!-- Footer content -->
        </div>
    </div>
    <div class="page">...</div>
    <div class="page">...</div>
    <div class="page">...</div>
</div>

I need to export the content of the editor, including multiple pages, into an RTF file. The content is structured within elements, and each page has sections like header, body, and footer. What’s the best approach to convert the editor’s HTML structure into RTF format? How can I handle things like multiple pages and rich text formatting while ensuring proper export to RTF?

I can't find a solution. I've already used bundle.js from html-to-rtf module, but I can't.

var html = document.getElementById('editor');
var rtf_content = htmlToRtf(html);
1
  • When you're calling htmlToRtf, it looks like you might need to pass it the HTML content as a string. You're passing the DOM element. Try var html = document.getElementById('editor').innerHTML; Commented Feb 24 at 23:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.