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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Export functionality

Thread ID:

Created:

Updated:

Platform:

Replies:

143030 Mar 1,2019 06:16 AM UTC Mar 5,2019 05:16 AM UTC JavaScript - EJ 2 3
loading
Tags: DocumentEditor
sampurnima kovi
Asked On March 1, 2019 06:16 AM UTC

Created server side functionality using file formats library, using code described in export section of the document editor.


    WordDocument document = WordDocument.Load(stream, GetFormatType(type.ToLower()));
    string sfdt = Newtonsoft.Json.JsonConvert.SerializeObject(document);
    document.Dispose();
    return sdft;

causes

:Self referencing loop detected for property 'Document' with type 'Syncfusion.DocIO.DLS.WordDocument'. Path 'Footnotes.Separator.Paragraphs[0].ChildEntities[0].CharacterFormat'.}

Environment : ASP.NET MVC
.NET Framework 4.5


Tried numerous word documents. There are lot's of suggestions on how to avoid this from Google search but none of them helped.
Some of them crashed IIS server (oops)

Love to hear your take on it. 

Thanks 



Ramya Thirugnanam [Syncfusion]
Replied On March 1, 2019 10:15 AM UTC

Hi Sampurnima,  
   
Thanks for contacting Syncfusion support.  
   
We were unable to reproduce the reported issue "Self-referencing loop detected for property 'Document'" from our side. And the code example which you have provided is related to import operation. So, from this we suspect you are trying to implement Import functionality for document editor. For your convenience, we have prepared an MVC Web API sample with Import and Export operation. Please find the sample from below link.  
   
   
If the same issue reproduced in this sample. kindly provide us an input document to replicate this issue. So that we will investigate on this and provide you appropriate solution at the earliest.  
   
Note: If you have any confidential data in your Word document, please replace with some dummy data and provide us the same. We just need your document to recreate the problem you face.  
 
 
Regards, 
Ramya T 


sampurnima kovi
Replied On March 3, 2019 03:58 AM UTC

Now I have different issues exporting PDF file.
I am creating blob and try to POST the form to the server
server does not receive any files

Here is the client side code


    var form = document.createElement("form");
    form.setAttribute('method',"post");
    form.setAttribute('encType',"multipart/form-data");
    form.setAttribute('action',"http://localhost:64927/convert.aspx");

 
    var outputFileName = document.createElement("input");
    outputFileName.type = "hidden";
    outputFileName.name = "outputFileName";
    outputFileName.value = "filename.pdf";
    form.appendChild(outputFileName);


    var outputFormat = document.createElement("input");
    outputFormat.type = "hidden";
    outputFormat.name = "outputFormat";
    outputFormat.value = "pdf";
    form.appendChild(outputFormat);


   // save the document as blob
    var exportedDocument = documentEditor.saveAsBlob('Docx');
   //create a form and using existing fields
    var formData = new FormData(form);
     // send the file name
    formData.append('fileName', 'sample.docx');
/   // send the blob
    formData.append('data', exportedDocument);
  



    fetch(form.action, {
        method: form.method,
        body: formData 
    }).then(function(res) {
        if (!res.ok) {
            console.log('something unexpected happened')
        }
        res.text().then(function(text) {
            console.log(text);
        })
    })


------------------- server side code ----

I am using asp.net mvc
public partial class _convert : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        AddOnPreRenderCompleteAsync(
            new BeginEventHandler(BeginAsyncOperation),
            new EndEventHandler(EndAsyncOperation)
        );
    }
    IAsyncResult BeginAsyncOperation(object sender, EventArgs e,
       AsyncCallback cb, object state)
    {

        Func  convert = ConvertData;
        var asyncState = new AsyncState(convert, state);
        return convert.BeginInvoke(cb, asyncState);
    }
    void EndAsyncOperation(IAsyncResult ar)
    {
        var asyncState = (AsyncState)ar.AsyncState;
        var del = (Func)asyncState.Del;
        var rc = del.EndInvoke(ar);
        Response.Write(rc);
    }


    public string ConvertData()
    {

          // THIS IS WHERE IT FAILS, always  return 0 file count
           if (Request.Files.Count <= 0)
            {
                errorString = "[{\"successful\":false,\"errorCode\":-14}]";
                return (errorString);
            }
            HttpPostedFile postedFile = Request.Files[0];
            string file_name = postedFile.FileName;
            if (string.IsNullOrEmpty(file_name))
            {
                errorString = "[{\"successful\":false,\"errorCode\":-15}]";
                return (errorString);
            }

            if (postedFile.ContentLength <= 0)
            {
                errorString = "[{\"successful\":false,\"errorCode\":-16}]";
                return (errorString);
            }
           .......

}


 it always says, the file count is zero. Spend whole day, totally stumped

Am I missing something?

Thanks
    

Ramya Thirugnanam [Syncfusion]
Replied On March 5, 2019 05:16 AM UTC

Hi Sampurnima,    
Thanks for contacting Syncfusion support.    
The reported issue occurs due to the wrong usage of 'saveAsBlob' method. This method returns a 'Promise' object but in your client-side code you are trying to access the Promise object as blob. So, due to this only this issue occurs. So, please modify the client-side code as below to resolve this issue.  
   
var form = document.createElement("form");  
form.setAttribute('method', "post");  
form.setAttribute('encType', "multipart/form-data");  
form.setAttribute('action', "http://localhost:64927/convert.aspx");  
  
var outputFileName = document.createElement("input");  
outputFileName.type = "hidden";  
outputFileName.name = "outputFileName";  
outputFileName.value = "filename.pdf";  
form.appendChild(outputFileName);  
  
var outputFormat = document.createElement("input");  
outputFormat.type = "hidden";  
outputFormat.name = "outputFormat";  
outputFormat.value = "pdf";  
form.appendChild(outputFormat);  
  
// save the document as blob  
documentEditor.saveAsBlob('Docx').then(function (exportedDocument) {  
    //create a form and using existing fields  
    var formData = new FormData(form);  
    // send the file name  
    formData.append('fileName', 'sample.docx');  
    // send the blob  
    formData.append('data', exportedDocument);  
  
    fetch(form.action, {  
        method: form.method,  
        body: formData  
    }).then(function (res) {  
        if (!res.ok) {  
            console.log('something unexpected happened')  
        }  
        res.text().then(function (text) {  
            console.log(text);  
        })  
    })  
});  
  
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

Live Chat Icon For mobile
Live Chat Icon