This commit is contained in:
amitm02
2018-08-29 18:36:48 +03:00
parent a710483918
commit 010fde6258
17 changed files with 140 additions and 12 deletions

View File

@ -0,0 +1,27 @@
import * as JSZip from "jszip";
import * as fastXmlParser from "fast-xml-parser";
import { convertToXmlComponent, parseOptions, ImportedXmlComponent } from "file/xml-components";
export class ImportDocx {
constructor() {
}
read(data) : Promise<any> {
return new Promise((resolve) => {
JSZip.loadAsync(data).then((zipContent) => {
let headerContent = zipContent['files']['word/header2.xml'];
headerContent.async('text').then((xmlData : string) => {
console.log('\n\n-------\n\n');
console.log('headerContent', JSON.stringify(xmlData, null, 2));
console.log('\n\n-------\n\n');
const jsonObj = fastXmlParser.parse(xmlData, parseOptions);
let xmlComp = convertToXmlComponent('w:hdr', jsonObj['w:hdr']) as ImportedXmlComponent;
resolve(xmlComp);
})
});
})
}
}