mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
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:
@@ -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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user