From 57680159fc1f90a2b38dbe2c91d4909c4b715373 Mon Sep 17 00:00:00 2001 From: Dolan Miu Date: Wed, 18 May 2016 17:09:50 +0100 Subject: [PATCH] made express packer work --- ts/export/packer/express.ts | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/ts/export/packer/express.ts b/ts/export/packer/express.ts index 906d32cae5..87ab026b37 100644 --- a/ts/export/packer/express.ts +++ b/ts/export/packer/express.ts @@ -2,12 +2,27 @@ import {Packer} from "./packer"; import * as fs from "fs"; import * as express from "express"; import {Document} from "../../docx/document"; +import {Properties} from "../../properties"; +import {DefaultStylesFactory} from "../../styles/factory" export class ExpressPacker extends Packer { private res: express.Response; - constructor(document: Document, res: express.Response) { - super(document, null, null); + constructor(document: Document, res: express.Response, styles?: any, properties?: Properties) { + 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.on('close', () => { @@ -15,7 +30,7 @@ export class ExpressPacker extends Packer { }); } - pack() { + pack(name: string): void { this.res.attachment(name + ".docx"); super.pack(this.res); }