diff --git a/src/export/packer/packer.spec.ts b/src/export/packer/packer.spec.ts index 5500144eff..b2c3e21836 100644 --- a/src/export/packer/packer.spec.ts +++ b/src/export/packer/packer.spec.ts @@ -37,6 +37,14 @@ describe("Packer", () => { }); }); + describe("#toString()", () => { + it("should return a non-empty string", async () => { + const result = await Packer.toString(file); + + assert.isAbove(result.length, 0); + }); + }); + describe("#toBuffer()", () => { it("should create a standard docx file", async function () { this.timeout(99999999); diff --git a/src/export/packer/packer.ts b/src/export/packer/packer.ts index 56d604fe18..4d047f7381 100644 --- a/src/export/packer/packer.ts +++ b/src/export/packer/packer.ts @@ -13,6 +13,17 @@ export enum PrettifyType { } export class Packer { + public static async toString(file: File, prettify?: boolean | PrettifyType): Promise { + const zip = this.compiler.compile(file, prettify); + const zipData = await zip.generateAsync({ + type: "string", + mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + compression: "DEFLATE", + }); + + return zipData; + } + public static async toBuffer(file: File, prettify?: boolean | PrettifyType): Promise { const zip = this.compiler.compile(file, prettify); const zipData = await zip.generateAsync({