mirror of
https://github.com/documenso/documenso.git
synced 2026-07-25 17:35:05 +10:00
fix: cleanup konva stages during field insertion (#2347)
This commit is contained in:
@@ -32,8 +32,8 @@ export const insertFieldInPDFV2 = async ({
|
|||||||
['Noto Sans Korean']: [path.join(fontPath, 'noto-sans-korean.ttf')],
|
['Noto Sans Korean']: [path.join(fontPath, 'noto-sans-korean.ttf')],
|
||||||
});
|
});
|
||||||
|
|
||||||
const stage = new Konva.Stage({ width: pageWidth, height: pageHeight });
|
let stage: Konva.Stage | null = new Konva.Stage({ width: pageWidth, height: pageHeight });
|
||||||
const layer = new Konva.Layer();
|
let layer: Konva.Layer | null = new Konva.Layer();
|
||||||
|
|
||||||
// Render the fields onto the layer.
|
// Render the fields onto the layer.
|
||||||
for (const field of fields) {
|
for (const field of fields) {
|
||||||
@@ -61,5 +61,13 @@ export const insertFieldInPDFV2 = async ({
|
|||||||
const canvas = layer.canvas._canvas as unknown as Canvas;
|
const canvas = layer.canvas._canvas as unknown as Canvas;
|
||||||
|
|
||||||
// Embed the SVG into the PDF
|
// Embed the SVG into the PDF
|
||||||
return await canvas.toBuffer('pdf');
|
const pdf = await canvas.toBuffer('pdf');
|
||||||
|
|
||||||
|
stage.destroy();
|
||||||
|
layer.destroy();
|
||||||
|
|
||||||
|
stage = null;
|
||||||
|
layer = null;
|
||||||
|
|
||||||
|
return pdf;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user