We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

List type & export sfdt

Thread ID:

Created:

Updated:

Platform:

Replies:

142715 Feb 16,2019 01:17 AM UTC Feb 18,2019 09:31 AM UTC JavaScript - EJ 2 1
loading
Tags: DocumentEditor
sampurnima kovi
Asked On February 16, 2019 01:17 AM UTC


1. How to get ListType when the cursor is in list. I wan't to find out whether it is bulleted list or numbered list

2. When I export a document it always appends .sfdt to the filename. Is there way to override this.

Thanks for all the help, you guys rock

Ramya Thirugnanam [Syncfusion]
Replied On February 18, 2019 09:31 AM UTC

Hi Sampurnima,  
   
Thank you for contacting Syncfusion support.  
   
Regarding “get ListType when the cursor is in list”  
   
In our DocumentEditor control, we can get selected list type by using ‘listText’ property in SelectionParagraphFormat class.   
   
Sample Code  
function GetListType() {  
if (documenteditor.selection.paragraphFormat.listId !== -1) {  
    // Unicode for Dot Bullet  
    var dotBullet = '\uf0b7';  
    // Unicode for Circle Bullet  
    var circleBullet = '\uf06f' + '\u0020';  
    // Unicode for Square Bullet  
    var squareBullet = '\uf0a7';  
    // Unicode for Flower Bullet  
    var flowerBullet = '\uf076';  
    // Unicode for Arrow Bullet  
    var arrowBullet = '\uf0d8';  
    // Unicode for Tick Bullet  
    var tickBullet = '\uf0fc';  
   
    var listText = documenteditor.selection.paragraphFormat.listText;  
    if (listText == dotBullet || listText == circleBullet || listText == squareBullet ||listText == flowerBullet || listText == arrowBullet || listText == tickBullet) {  
        return "Bulleted list";  
    } else {  
        return "Numbered list";  
    }  
} else {  
    return "Cursor not in list";  
}  
}  
  
   
   
Regarding “appends .sfdt to the filename. Is there way to override this?”  
   
In our DocumentEditor control, if you export a document as SFDT format ‘.sfdt’ extension will append to the filename to denote the that file is in SFDT format. So, it not possible to override this default behavior of ‘save method of Document Editor.  
   
So, we suggest you use ‘saveAsBlob which return the document content as ‘Blob’ and it can be downloaded in to client machine with custom name by using below code.  
   
documenteditor.saveAsBlob('Sfdt').then(function (blob) {  
var fileName = 'sample.json';  
if (navigator.msSaveBlob) {  
    navigator.msSaveBlob(blob, fileName);  
} else {  
    var downloadAnchorTag: any = document.createElementNS('http://www.w3.org/1999/xhtml','a');  
    if ('download' in downloadAnchorTag) {  
        downloadAnchorTag.download = fileName;  
        var dataUrl: string = window.URL.createObjectURL(blob);  
        downloadAnchorTag.rel='nofollow' href = dataUrl;  
        var event: MouseEvent = document.createEvent('MouseEvent');  
        event.initEvent('click', true, true);  
        downloadAnchorTag.dispatchEvent(event);  
        setTimeout((): void => {  
            window.URL.revokeObjectURL(dataUrl);  
            dataUrl = undefined;  
        });  
    } else {  
        var extension = fileName.substring(fileName.indexOf('.') + 1);  
        if (extension !== 'docx' && extension !== 'xlsx') {  
            let url: string = window.URL.createObjectURL(blob);  
            let isPopupBlocked: Window = window.open(url, '_blank');  
            if (!isPopupBlocked) {  
                window.location.rel='nofollow' href = url;  
            }  
        } else {  
            let reader: FileReader = new FileReader();  
            reader.onloadend = () => {  
                let isPopupBlocked: Window = window.open(reader.result as string, '_blank');  
                if (!isPopupBlocked) {  
                    window.location.rel='nofollow' href = reader.result as string;  
                }  
            }  
            reader.readAsDataURL(blob);  
        }  
    }  
}  
})  
   
  
   
   
Note: SFDT denotes ‘Syncfusion Document Text’ which is our internal structure to load and export the content from DocumentEditor.  
Regards, 
Ramya T 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;