creates working docx file

This commit is contained in:
Dolan Miu
2016-04-05 22:11:21 +01:00
parent a4b6ea562f
commit 7d8bac54dc
2 changed files with 18 additions and 6 deletions

View File

@ -28,22 +28,29 @@ export abstract class Packer {
pack(output: any): void {
this.archive.pipe(output);
console.log(appRoot.path);
console.log(appRoot.path + "/template");
this.archive.bulk([
{
expand: true,
cwd: appRoot.path + '/template',
cwd: appRoot.path + "/template",
src: ['**', '**/.rels']
}
]);
//this.archive.directory(__dirname + "/template", "/");
//this.archive.file(appRoot.path + "/template/[Content_Types].xml", { name: "[Content_Types].xml" });
//console.log(__dirname + "/packer.js");
//this.archive.file(__dirname + "/packer.js", { name: "/[Content_Types].xml" });
/*this.archive.directory(appRoot.path + "/template", {
name: "/root/g.txt",
prefix: "root"
});*/
var xmlDocument = xml(this.formatter.format(this.document));
var xmlStyle = xml(this.style);
var xmlProperties = xml(this.formatter.format(this.properties));
console.log(JSON.stringify(this.formatter.format(this.document), null, " "));
console.log(xmlDocument);
//console.log(JSON.stringify(this.formatter.format(this.document), null, " "));
//console.log(xmlDocument);
this.archive.append(xmlDocument, {
name: 'word/document.xml'
@ -58,5 +65,6 @@ console.log(appRoot.path);
});
this.archive.finalize();
console.log("done");
}
}

View File

@ -8,12 +8,15 @@ import {assert} from "chai";
import {Document} from "../docx/document"
import {Properties} from "../properties"
import {DefaultStyle} from "../style/default"
import {Paragraph} from "../docx/paragraph"
describe.only("Packer", () => {
var packer: LocalPacker;
beforeEach(() => {
var document = new Document();
var paragraph = new Paragraph("test text");
document.addParagraph(paragraph);
var properties = new Properties({
title: "test document"
});
@ -22,8 +25,9 @@ describe.only("Packer", () => {
describe('#pack()', () => {
it("should create a standard docx file", () => {
it("should create a standard docx file", (done) => {
packer.pack();
setTimeout(done, 3000);
});
});
});