creates working docx file
This commit is contained in:
@ -28,22 +28,29 @@ export abstract class Packer {
|
|||||||
|
|
||||||
pack(output: any): void {
|
pack(output: any): void {
|
||||||
this.archive.pipe(output);
|
this.archive.pipe(output);
|
||||||
console.log(appRoot.path);
|
console.log(appRoot.path + "/template");
|
||||||
this.archive.bulk([
|
this.archive.bulk([
|
||||||
{
|
{
|
||||||
expand: true,
|
expand: true,
|
||||||
cwd: appRoot.path + '/template',
|
cwd: appRoot.path + "/template",
|
||||||
src: ['**', '**/.rels']
|
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 xmlDocument = xml(this.formatter.format(this.document));
|
||||||
var xmlStyle = xml(this.style);
|
var xmlStyle = xml(this.style);
|
||||||
var xmlProperties = xml(this.formatter.format(this.properties));
|
var xmlProperties = xml(this.formatter.format(this.properties));
|
||||||
|
|
||||||
console.log(JSON.stringify(this.formatter.format(this.document), null, " "));
|
//console.log(JSON.stringify(this.formatter.format(this.document), null, " "));
|
||||||
console.log(xmlDocument);
|
//console.log(xmlDocument);
|
||||||
|
|
||||||
this.archive.append(xmlDocument, {
|
this.archive.append(xmlDocument, {
|
||||||
name: 'word/document.xml'
|
name: 'word/document.xml'
|
||||||
@ -58,5 +65,6 @@ console.log(appRoot.path);
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.archive.finalize();
|
this.archive.finalize();
|
||||||
|
console.log("done");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,12 +8,15 @@ import {assert} from "chai";
|
|||||||
import {Document} from "../docx/document"
|
import {Document} from "../docx/document"
|
||||||
import {Properties} from "../properties"
|
import {Properties} from "../properties"
|
||||||
import {DefaultStyle} from "../style/default"
|
import {DefaultStyle} from "../style/default"
|
||||||
|
import {Paragraph} from "../docx/paragraph"
|
||||||
|
|
||||||
describe.only("Packer", () => {
|
describe.only("Packer", () => {
|
||||||
var packer: LocalPacker;
|
var packer: LocalPacker;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
var document = new Document();
|
var document = new Document();
|
||||||
|
var paragraph = new Paragraph("test text");
|
||||||
|
document.addParagraph(paragraph);
|
||||||
var properties = new Properties({
|
var properties = new Properties({
|
||||||
title: "test document"
|
title: "test document"
|
||||||
});
|
});
|
||||||
@ -22,8 +25,9 @@ describe.only("Packer", () => {
|
|||||||
|
|
||||||
describe('#pack()', () => {
|
describe('#pack()', () => {
|
||||||
|
|
||||||
it("should create a standard docx file", () => {
|
it("should create a standard docx file", (done) => {
|
||||||
packer.pack();
|
packer.pack();
|
||||||
|
setTimeout(done, 3000);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
Reference in New Issue
Block a user