Added toStream export function
New Function returns a NodeJS readable stream that allows piping DOCX document data to stream.
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import { File } from "@file/file";
|
||||
import { Stream } from "stream";
|
||||
|
||||
import { Compiler } from "./next-compiler";
|
||||
|
||||
@ -46,5 +47,17 @@ export class Packer {
|
||||
return zipData;
|
||||
}
|
||||
|
||||
public static async toStream(file: File, prettify?: boolean | PrettifyType): Promise<Stream> {
|
||||
const zip = this.compiler.compile(file, prettify);
|
||||
const zipData = zip.generateNodeStream({
|
||||
type: "nodebuffer",
|
||||
streamFiles: true,
|
||||
mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
compression: "DEFLATE",
|
||||
});
|
||||
|
||||
return zipData;
|
||||
}
|
||||
|
||||
private static readonly compiler = new Compiler();
|
||||
}
|
||||
|
Reference in New Issue
Block a user