Unable to open docx file

We're able to open a .doc file from a blob, but we're getting the following error when attempting to open a .docx file from a blob.

The following retrieves the file:

setSelectedFile(file) {
this.restService.retrieveFile(file.Key)
.subscribe((response: any) => {
var byteArray = new Uint8Array(response.Body.data);
const blob = new Blob([byteArray], {type: response.Body.type})
let fileData: File;
if (file.Key.substr(file.Key.lastIndexOf('.')) !== '.docx') {
fileData = new File([blob], file.Key, {
type: 'application/msword',
lastModified: new Date(file.LastModified).getTime()
});
} else {
fileData = new File([blob], file.Key, {
type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
lastModified: new Date(file.LastModified).getTime()
});
}
this.selectedFile.next(fileData);
}, (error) => {})
}


The file is then passed into the following function, which calls the dockerized API provided by Syncfusion:

loadFile(file): void {
console.log(`this is the file: `, file);
this.fileName = file.name;
let ajax: XMLHttpRequest = new XMLHttpRequest();
ajax.open('POST', 'http://localhost:6002/api/documenteditor/Import', true);
// ajax.setRequestHeader('Access-Control-Allow-Origin', '*');
ajax.onreadystatechange = () => {
if (ajax.readyState === 4) {
if (ajax.status === 200 || ajax.status === 304) {
// open SFDT text in document editor
this.documentEditor.open(ajax.responseText);
}
}
}
let formData: FormData = new FormData();
formData.append('files', file);
ajax.send(formData);
}

The following error is in the console of the dockerized API:

word-processor-server_1 | fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[0]

word-processor-server_1 | An unhandled exception has occurred while executing the request

word-processor-server_1 | Syncfusion.Compression.Zip.ZipException: Zip exception.Can't locate end of central directory record. Possible wrong file format or archive is corrupt.

word-processor-server_1 | at Syncfusion.Compression.Zip.ZipArchive.Open(Stream stream, Boolean closeStream)

word-processor-server_1 | at Syncfusion.DocIO.DLS.Convertors.DocxParser.Read(Stream docStream, WordDocument document)

word-processor-server_1 | at Syncfusion.DocIO.DLS.WordDocument.OpenDocx(Stream stream)

word-processor-server_1 | at Syncfusion.DocIO.DLS.WordDocument.OpenInternal(Stream stream, FormatType formatType, String password)

word-processor-server_1 | at Syncfusion.EJ2.DocumentEditor.WordDocument.Load(Stream stream, FormatType type)

word-processor-server_1 | at EJ2DocumentEditorServer.Controllers.DocumentEditorController.Import(IFormCollection data) in /source/src/ej2-documenteditor-server/Controllers/DocumentEditorController.cs:line 49

word-processor-server_1 | at lambda_method(Closure , Object , Object[] )

word-processor-server_1 | at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()

word-processor-server_1 | at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()

word-processor-server_1 | at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)

word-processor-server_1 | at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)

word-processor-server_1 | at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()

word-processor-server_1 | at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()

word-processor-server_1 | at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)

word-processor-server_1 | at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)

word-processor-server_1 | at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()

word-processor-server_1 | at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()

word-processor-server_1 | at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)

word-processor-server_1 | at Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.Invoke(HttpContext context)

word-processor-server_1 | at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)



4 Replies

SM Suriya Murugan Syncfusion Team December 1, 2021 11:51 AM UTC

Hi Betty 

Syncfusion Greetings! 

Can you please share the document which you tried at your end? That will be helpful for us to proceed further and provide you 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, 
Suriya M. 



BJ Betty Jo Brotherton December 2, 2021 01:36 PM UTC

Attached are a few of the documents we've tried that have resulted in errors.


Attachment: DOCX_file_examples_cecd0bec.zip


BJ Betty Jo Brotherton replied to Suriya Murugan December 2, 2021 09:12 PM UTC

Documents attached in previous message.



KB Kurthis Banu Abdul Majeeth Syncfusion Team December 6, 2021 11:52 AM UTC

Hi Betty, 

Document Name: file-sample_500kB (2).docx 

On further analyzing the reported document (file-sample_500kB (2).docx), we found that the document has some invalid font names. When opening this document with Microsoft Word desktop app these invalid font names are considered as fonts that are not available in machine and substitutes alternate font automatically on its own.    
You can find the substituted font information in Microsoft Word using “File -> Options -> Advanced -> Font substitution”.   


 
   


 
Please find the list of invalid fonts used in your document from below:  
  
1. Liberation Sans;Arial  
2. Liberation Serif;Times New Roma  
3. Open Sans;Arial  
4. OpenSymbol;Arial Unicode MS  
  
Whereas in Syncfusion Document editor component it is not possible to detect whether a font is installed in the machine or not. This is a browser level limitation in accessing the fonts installed in machine.  if the Hence, we recommend you open this document in Microsoft Word and save it as new file to store this font substitution information in the document. Once this alternate font information is stored in the document, Syncfusion Document editor component considered this alternate font and displays the text using alternate font.    


 
For your knowledge, please find the font substitution information stored in the original document and the resaved (open and saved using Microsoft Word desktop app) document.  
 
corporate_40d03f81.docx 
Resaved-document.docx 
 
Missing font  
Substituted font  
Liberation Serif  
Times New Roman  
OpenSymbol  
Arial Unicode MS  
Liberation Sans  
Arial  
Open Sans  
Arial  


 
 
 
Missing font  
Substituted font  
OpenSymbol  
Arial Unicode MS  
Liberation Serif  
Times New Roman  
Droid Sans Fallback  
Segoe UI  
FreeSans  
Cambria  
Liberation Serif;Times New Roma  
Times New Roman  
Liberation Sans;Arial  
Arial  
OpenSymbol;Arial Unicode MS  
Cambria  
Open Sans;Arial  
Segoe UI  

For your ease, we have attached the resaved (open and saved using Microsoft Word desktop app) document which has all the necessary font substitution details. 
Modified document:  
 

 
Above two documents, first document have some corrupted issue not able to open in MS word Application also ,and second one has empty file. So, could you please share the original document to check further. This will be more helpful to reproduce the same issue at our end and provide you a solution to you at the earliest. 

Please let us know if you have questions. 

Regards, 
Kurthis Banu A. 


Loader.
Up arrow icon