feat: add Sign PDF tool (draw/type/upload signatures, place on a PDF) (#370)

Draw, type, or upload a signature and place resizable/rotatable copies across PDF pages; output flattened server-side with PyMuPDF. Visual electronic signature, not cryptographic. New interactive-sign display mode (pdf.js + Konva) and a custom docs-pool route.
This commit is contained in:
SnapOtter
2026-06-29 11:01:25 +08:00
committed by GitHub
parent 1c202c6ef0
commit 0cdd560ac4
51 changed files with 2223 additions and 10 deletions
+29
View File
@@ -0,0 +1,29 @@
import { describe, expect, it } from "vitest";
import { rotatedBoundingBox, toNormalizedRect } from "@/lib/sign-geometry";
describe("sign-geometry", () => {
it("normalizes a pixel rect against the render size", () => {
expect(toNormalizedRect({ x: 50, y: 100, w: 25, h: 10 }, 100, 200)).toEqual({
x: 0.5,
y: 0.5,
w: 0.25,
h: 0.05,
});
});
it("bounding box of an unrotated rect is unchanged", () => {
expect(rotatedBoundingBox(40, 20, 0)).toEqual({ w: 40, h: 20 });
});
it("bounding box of a 90deg rotation swaps w/h", () => {
const b = rotatedBoundingBox(40, 20, 90);
expect(b.w).toBeCloseTo(20, 5);
expect(b.h).toBeCloseTo(40, 5);
});
it("bounding box grows for a 45deg rotation", () => {
const b = rotatedBoundingBox(40, 20, 45);
expect(b.w).toBeCloseTo((40 + 20) / Math.SQRT2, 5);
expect(b.h).toBeCloseTo((40 + 20) / Math.SQRT2, 5);
});
});