made express packer work
This commit is contained in:
@ -2,12 +2,27 @@ import {Packer} from "./packer";
|
|||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
import {Document} from "../../docx/document";
|
import {Document} from "../../docx/document";
|
||||||
|
import {Properties} from "../../properties";
|
||||||
|
import {DefaultStylesFactory} from "../../styles/factory"
|
||||||
|
|
||||||
export class ExpressPacker extends Packer {
|
export class ExpressPacker extends Packer {
|
||||||
private res: express.Response;
|
private res: express.Response;
|
||||||
|
|
||||||
constructor(document: Document, res: express.Response) {
|
constructor(document: Document, res: express.Response, styles?: any, properties?: Properties) {
|
||||||
super(document, null, null);
|
if (!styles) {
|
||||||
|
var stylesFactory = new DefaultStylesFactory();
|
||||||
|
styles = stylesFactory.newInstance()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!properties) {
|
||||||
|
properties = new Properties({
|
||||||
|
creator: "Shan Fu",
|
||||||
|
revision: "1",
|
||||||
|
lastModifiedBy: "Shan Fu"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
super(document, styles, properties);
|
||||||
this.res = res;
|
this.res = res;
|
||||||
|
|
||||||
this.res.on('close', () => {
|
this.res.on('close', () => {
|
||||||
@ -15,7 +30,7 @@ export class ExpressPacker extends Packer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pack() {
|
pack(name: string): void {
|
||||||
this.res.attachment(name + ".docx");
|
this.res.attachment(name + ".docx");
|
||||||
super.pack(this.res);
|
super.pack(this.res);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user