This commit is contained in:
Morten Olsen
2023-03-26 22:15:07 +02:00
commit 9b1a067d56
80 changed files with 7889 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
import latex from "node-latex";
import { Readable } from "stream";
const latexToPdf = (doc: string) =>
new Promise<Buffer>((resolve, reject) => {
const chunks: Buffer[] = [];
const input = new Readable();
input.push(doc);
input.push(null);
const latexStream = latex(input);
latexStream.on("data", (chunk) => {
chunks.push(Buffer.from(chunk));
});
latexStream.on("finish", () => {
const result = Buffer.concat(chunks);
resolve(result);
});
latexStream.on("error", (err) => {
reject(err);
});
});
export { latexToPdf };