diff --git a/package.json b/package.json index c4636649bb..4512962bed 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,9 @@ "dependencies": { "@types/archiver": "^1.3.4", "@types/express": "^4.0.35", + "@types/request": "^2.0.3", "archiver": "^1.3.0", + "request": "^2.83.0", "xml": "^1.0.1" }, "author": "Dolan Miu", diff --git a/ts/export/packer/express.ts b/ts/export/packer/express.ts index 7277051c72..b0c638f38b 100644 --- a/ts/export/packer/express.ts +++ b/ts/export/packer/express.ts @@ -1,9 +1,11 @@ import * as express from "express"; + import { Document } from "../../docx/document"; import { Media } from "../../media"; import { Numbering } from "../../numbering"; import { Properties } from "../../properties"; import { Styles } from "../../styles"; +import { IPackOptions } from "./pack-options"; import { Packer } from "./packer"; export class ExpressPacker extends Packer { @@ -18,7 +20,7 @@ export class ExpressPacker extends Packer { }); } - public pack(name: string): void { + public pack(name: string, options: IPackOptions): void { this.res.attachment(`${name}.docx`); super.compile(this.res); } diff --git a/ts/export/packer/local.ts b/ts/export/packer/local.ts index d255147b16..67ddc336fd 100644 --- a/ts/export/packer/local.ts +++ b/ts/export/packer/local.ts @@ -1,9 +1,11 @@ import * as fs from "fs"; + import { Document } from "../../docx/document"; import { Media } from "../../media"; import { Numbering } from "../../numbering"; import { Properties } from "../../properties"; import { Styles } from "../../styles"; +import { IPackOptions } from "./pack-options"; import { Packer } from "./packer"; export class LocalPacker extends Packer { @@ -13,7 +15,7 @@ export class LocalPacker extends Packer { super(document, styles, properties, numbering, media); } - public pack(path: string): void { + public pack(path: string, options?: IPackOptions): void { path = path.replace(/.docx$/, ""); this.stream = fs.createWriteStream(`${path}.docx`); super.compile(this.stream); diff --git a/ts/export/packer/pack-options.ts b/ts/export/packer/pack-options.ts new file mode 100644 index 0000000000..466de05f93 --- /dev/null +++ b/ts/export/packer/pack-options.ts @@ -0,0 +1,3 @@ +export interface IPackOptions { + pdf: boolean; +} diff --git a/ts/export/packer/packer.ts b/ts/export/packer/packer.ts index 6a162bca65..2f35b6fa3d 100644 --- a/ts/export/packer/packer.ts +++ b/ts/export/packer/packer.ts @@ -3,6 +3,7 @@ import * as express from "express"; import * as fs from "fs"; import * as path from "path"; import * as xml from "xml"; + import { Document } from "../../docx"; import { Media } from "../../media"; import { Numbering } from "../../numbering"; @@ -10,6 +11,7 @@ import { Properties } from "../../properties"; import { Styles } from "../../styles"; import { DefaultStylesFactory } from "../../styles/factory"; import { Formatter } from "../formatter"; +import { IPackOptions } from "./pack-options"; const TEMPLATE_PATH = path.resolve(__dirname, "../../../template"); @@ -44,6 +46,8 @@ export abstract class Packer { }); } + public abstract pack(path: string, options?: IPackOptions): void; + protected compile(output: fs.WriteStream | express.Response): void { this.archive.pipe(output); this.archive.glob("**", { @@ -88,4 +92,8 @@ export abstract class Packer { this.archive.finalize(); } + + protected convertToPdf(): void { + // TODO + } } diff --git a/ts/export/packer/pdf-convert-wrapper.ts b/ts/export/packer/pdf-convert-wrapper.ts new file mode 100644 index 0000000000..e69de29bb2