mirror of
https://github.com/documenso/documenso.git
synced 2025-11-21 20:21:38 +10:00
✨🚧 signDocument using node signpdf and custom placeholder insert
This commit is contained in:
@ -7,6 +7,7 @@ import prisma from "@documenso/prisma";
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import { Document as PrismaDocument } from "@prisma/client";
|
||||
import { getDocument } from "@documenso/lib/query";
|
||||
import { signDocument } from "@documenso/signing/signDocument";
|
||||
|
||||
async function getHandler(req: NextApiRequest, res: NextApiResponse) {
|
||||
const user = await getUserFromToken(req, res);
|
||||
@ -24,7 +25,11 @@ async function getHandler(req: NextApiRequest, res: NextApiResponse) {
|
||||
if (!document)
|
||||
res.status(404).end(`No document with id ${documentId} found.`);
|
||||
|
||||
const buffer: Buffer = Buffer.from(document.document.toString(), "base64");
|
||||
const signedDocumentAsBase64 = await signDocument(
|
||||
document.document.toString()
|
||||
);
|
||||
|
||||
const buffer: Buffer = Buffer.from(signedDocumentAsBase64, "base64");
|
||||
res.setHeader("Content-Type", "application/pdf");
|
||||
res.setHeader(
|
||||
"Content-Disposition",
|
||||
|
||||
Reference in New Issue
Block a user