Initial scaffold of pdf convert
This commit is contained in:
@ -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",
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
3
ts/export/packer/pack-options.ts
Normal file
3
ts/export/packer/pack-options.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export interface IPackOptions {
|
||||
pdf: boolean;
|
||||
}
|
@ -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
|
||||
}
|
||||
}
|
||||
|
0
ts/export/packer/pdf-convert-wrapper.ts
Normal file
0
ts/export/packer/pdf-convert-wrapper.ts
Normal file
Reference in New Issue
Block a user