caiyexiang / html-docx-js-typescript

Convert HTML documents to docx format.
MIT License
85 stars 18 forks source link

The document could not be opened. The file isn’t in the correct format. #4

Closed ZeeshanAslam2016 closed 4 years ago

ZeeshanAslam2016 commented 4 years ago

On mobile and mac when i try to open download file it always show me the message "The document could not be opened. The file isn’t in the correct format." I am using this with angular 8.

caiyexiang commented 4 years ago

Hey! I try my package in angular9 / macOs10.15.5,and I can open the document in MS Word。

caiyexiang commented 4 years ago

Here is my test code:

ngOnInit() {
    const html = `<!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Document</title>
    </head>
    <body>
      <div>good</div>
    </body>
    </html>`;
    asBlob(html).then(data => {
      saveAs(data);
    })
  }
caiyexiang commented 4 years ago

Maybe you are not using the correct html format, the html string should be a complete html document format including <!DOCTYPE html> and <html><head><body> label etc.