Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
fix
Marc Seitz81e62ba5bb8e
diff --git a/pages/api/mupdf/convert-page.ts b/pages/api/mupdf/convert-page.tsindex c7de9495..2c62a24c 100644--- a/pages/api/mupdf/convert-page.ts+++ b/pages/api/mupdf/convert-page.ts@@ -62,7 +62,7 @@ export default async (req: NextApiRequest, res: NextApiResponse) => {const links = page.getLinks();const embeddedLinks = links.map((link: any) => link.getURI());- const pixmap = page.toPixmap(+ let pixmap = page.toPixmap(// [3, 0, 0, 3, 0, 0], // scale 3x // to 300 DPIdoc_to_screen,mupdf.ColorSpace.DeviceRGB,@@ -71,9 +71,8 @@ export default async (req: NextApiRequest, res: NextApiResponse) => {);const pngBuffer = pixmap.asPNG(); // as PNG- pixmap.destroy(); // free memory- let buffer = Buffer.from(pngBuffer);+ let buffer = Buffer.from(pngBuffer, "binary");// get docId from url with starts with "doc_" with regexconst match = url.match(/(doc_[^\/]+)\//);@@ -89,6 +88,9 @@ export default async (req: NextApiRequest, res: NextApiResponse) => {docId: docId,});+ buffer = Buffer.alloc(0); // free memory+ pixmap.destroy(); // free memory+if (!data || !type) {throw new Error(`Failed to upload document page ${pageNumber}`);}