Use a default template

Hello
I have a need, please help me
I want to give users an editor to type text with a specific header and footer
I want to create a template file on the server so that each user can use that template and the user can write his own text inside it.
Is it possible to take the full text of the user and save it in the database or should the file be saved in the database?

12 Replies

SR Stephen Raj Chandra Sekar Syncfusion Team December 10, 2020 11:16 AM UTC

Hi yeadam, 
 
Reg. Is it possible to take the full text of the user and save it in the database or should the file be saved in the database? 
We can only save the entire document to the database. Also, In other way You can add text formfield in document and export the filled content to the database and retrieve it when you needed. 
 
 
Regards, 
Stephen Raj


YE yeadam December 10, 2020 10:34 PM UTC

Yes, I understand and thank you

Can you help me?
The easiest way is to open the file by default
Suppose I have a file named template.docx in the files folder. I want this template to load by default when loading the page.


SR Stephen Raj Chandra Sekar Syncfusion Team December 11, 2020 08:53 AM UTC

Hi yeadam, 
 
We have prepared a sample to open the default document. Kindly download it from below link. 
 
 
Code Snippet: 
Client-side code: 
 
 
        var documenteditor = containerInstance.documentEditor; 
        onLoadDefault(); 
        function onLoadDefault() { 
            var baseUrl = '/api/documenteditor/LoadDefault'; 
            var httpRequest = new XMLHttpRequest(); 
            httpRequest.open('POST', baseUrl, true); 
            httpRequest.onreadystatechange = function () { 
                if (httpRequest.readyState === 4) { 
                    if (httpRequest.status === 200 || httpRequest.status === 304) { 
                        documenteditor.open(httpRequest.responseText); 
                    } 
                } 
            }; 
            httpRequest.send(); 
        } 
 
 
Server-side code: 
        [AcceptVerbs("Post")] 
        [HttpPost] 
        [Route("LoadDefault")] 
        public string LoadDefault() 
        { 
            string path = hostingEnvironment.WebRootPath + "\\DefaultDocument\\Text-Formatting.docx"; 
//add you file path in above line. 
            if (!System.IO.File.Exists(path)) 
                return null;  
            Stream stream = System.IO.File.OpenRead(path); 
            stream.Position = 0; 
            WordDocument document = WordDocument.Load(stream, FormatType.Docx); 
            string json = Newtonsoft.Json.JsonConvert.SerializeObject(document); 
            document.Dispose(); 
            stream.Close(); 
            return json; 
        } 
 
Regards, 
Stephen Raj


YE yeadam December 12, 2020 06:55 AM UTC

Thank you very much

What method do you suggest if we want to put texts in different places of the page?
I tried to bookmark the sections in the default template file, and when a button was clicked, the text would be in the places marked with a bookmark.
What is your suggestion for this?


SR Stephen Raj Chandra Sekar Syncfusion Team December 14, 2020 10:46 AM UTC

Hi yeadam, 
 
Yes, We suggest you to proceed along with your approach, currently we don’t have any other options. 
 
Regards, 
Stephen Raj


YE yeadam December 14, 2020 08:56 PM UTC

Thank you
I could not do with the bookmark
I put some unique letters in the template file in the header and body and tried to do it by finding the letters and replacing them.
With the help of the following code


            // Find all the occurences of given text
            documenteditor.searchModule.findAll("RN");

            // Replace all the occurences of given text header
            documenteditor.searchModule.searchResults.replaceAll("yadam started...");

            // Find all the occurences of given text
            documenteditor.searchModule.findAll("RT");

            // Replace all the occurences of given text  body
            documenteditor.searchModule.searchResults.replaceAll("started yadam ");

               .
               .
               .

But when the letters are replaced, the header is removed


SR Stephen Raj Chandra Sekar Syncfusion Team December 15, 2020 12:02 PM UTC

Hi yeadam, 
 
We couldn’t find the exact use case of your requirement, So Its better to have a call to discuss further on this use case. We have created incident for this query under your direct trac account. We have updated details in that incident. Kindly check that incident for further follow-ups. 
 
Regards, 
Stephen Raj


YE yeadam December 15, 2020 07:10 PM UTC

Thank you very much for your excellent support
The problem was solved.
The problem was our code.
The problem we have is that we are developing an app for Arab countries.
That is why we are testing several companies in parallel on the component and one of them is your company
Our app needs to use Unicode
But your editor does not work very well in Arabic or Unicode mode. Pointer keys work in reverse to move between text.
Is there a solution to this problem?


HC Harini Chellappa Syncfusion Team December 16, 2020 06:53 AM UTC

Hi Yeadam, 

We are facing cursor related issues when typing RTL text. We have logged a defect report for this. We will include the fix in our upcoming EJ2 patch release, which is tentatively scheduled on Dec 30, 2020. Once included, will update you. You can track the fix status from the below link. 


Regards, 

Harini C 



YE yeadam January 1, 2021 08:08 PM UTC

Hi
I checked the demos of the site, apparently the problem of right to left has not been solved yet



SR Stephen Raj Chandra Sekar Syncfusion Team January 4, 2021 05:51 AM UTC

Hi yeadam, 
 
We're sorry to not make it possible to include the fix for the below promised issue in latest patch release v18.4.32. will include this in our upcoming EJ2 patch release which is tentatively scheduled on Jan 13th, 2021. We will update the status of the feedback link, once it is taken for implementation. You can track the status from below link. 
 
 
Regards, 
Stephen Raj


KB Kurthis Banu Abdul Majeeth Syncfusion Team January 14, 2021 12:34 PM UTC

Hi yeadam, 
  
Thank you for your patience.  
  
  
We are glad to announce that our patch release (v18.4.34) is rolled out successfully and In that release, we have added the fix for reported issue.      
  
  
 Please upgrade to the latest version packages to resolve this issue.      
  
  
  
  
The status of this reported issue can be tracked through below link:   
  
  
  
Please let us know if you have any other questions.  
  
  
Regards,   
  
Kurthis Banu A.  


Loader.
Up arrow icon