Import from Word

3 posts, 1 answers
  1. Julian
    Julian avatar
    11 posts
    Member since:
    Dec 2011

    Posted 28 Sep 2016 Link to this post

    Hi there, I'm using some code like this to import from Word.


                Using fileStream As New FileStream(Server.MapPath(FilePath), FileMode.Open, FileAccess.Read)
                End Using

    In principle this works fine. However, if text has been formatted as Heading 3 in Word, then it comes through as <p>My text</p> instead of <h3>My text</h3>.

    However, if I copy/paste from Word into the editor, then the <h3> tags are preserved. Any ideas why the import is not preserving the <h3> tags?

  2. Answer
    Rumen avatar
    13246 posts

    Posted 28 Sep 2016 Link to this post

    Hi Julian,

    The import and paste from Word options are based on two different technologies.

    The paste process is controlled by the browser and the operating system and the editor is just a consumer of the clipboard content, which only strips the unwanted formatting.

    While the importation of DOCX is actually a conversion from DOCX syntax to HTML content with the help of the Telerik RadWordsProcessing library.

    We are aware of the H -> P tag problem and we could propose the following solution for it: You can implement a custom client-side function that replaces the paragraphs having special classes TelerikHeading with the corresponding H elements with jQuery:

    Copy Code
    <telerik:RadEditor runat="server" ID="RadEditor1" OnClientLoad="OnClientLoad">
    <script type="text/javascript">
        function OnClientLoad(editor, args) {
        function fixHeadings(content) {
            var $ = $telerik.$;
            for (var i = 1; i <= 6; i++) {
                var headings = $(content).find("p.TelerikHeading" + i.toString());
                headings.each(function (index, item) {
                    var element = $(item);
                    var newH = $("<h" + i + "></h" + i + ">", {
                        html: element.html()

    Best regards,
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. Julian
    Julian avatar
    11 posts
    Member since:
    Dec 2011

    Posted 28 Sep 2016 in reply to Rumen Link to this post

    Great, thanks.
Back to Top