From dc4830d41babcf1c7e236df5a30e4b78cecd36e4 Mon Sep 17 00:00:00 2001 From: Amruth Pillai Date: Wed, 29 Apr 2026 21:42:20 +0200 Subject: [PATCH] chore: remove getSubsequentPageTopMarginStyle --- .../orpc/services/printer-styles.test.ts | 21 ------------------- .../orpc/services/printer-styles.ts | 9 -------- src/integrations/orpc/services/printer.ts | 19 +---------------- 3 files changed, 1 insertion(+), 48 deletions(-) delete mode 100644 src/integrations/orpc/services/printer-styles.test.ts delete mode 100644 src/integrations/orpc/services/printer-styles.ts diff --git a/src/integrations/orpc/services/printer-styles.test.ts b/src/integrations/orpc/services/printer-styles.test.ts deleted file mode 100644 index e9d338ade..000000000 --- a/src/integrations/orpc/services/printer-styles.test.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { describe, expect, it } from "vite-plus/test"; - -import { getSubsequentPageTopMarginStyle } from "./printer-styles"; - -describe("getSubsequentPageTopMarginStyle", () => { - it("uses print padding when the template applies page padding", () => { - expect(getSubsequentPageTopMarginStyle(12, 24)).toContain("@page { margin-top: 12pt; }"); - }); - - it("falls back to the resume page margin when no print padding is applied", () => { - expect(getSubsequentPageTopMarginStyle(0, 24)).toContain("@page { margin-top: 24pt; }"); - }); - - it("leaves the first PDF page unchanged", () => { - expect(getSubsequentPageTopMarginStyle(12, 24)).toContain("@page :first { margin-top: 0; }"); - }); - - it("returns null when there is no vertical spacing", () => { - expect(getSubsequentPageTopMarginStyle(0, 0)).toBeNull(); - }); -}); diff --git a/src/integrations/orpc/services/printer-styles.ts b/src/integrations/orpc/services/printer-styles.ts deleted file mode 100644 index a0d80fcd5..000000000 --- a/src/integrations/orpc/services/printer-styles.ts +++ /dev/null @@ -1,9 +0,0 @@ -export function getSubsequentPageTopMarginStyle(pagePaddingY: number, marginY: number): string | null { - const effectivePaddingY = pagePaddingY > 0 ? pagePaddingY : marginY; - if (effectivePaddingY <= 0) return null; - - return ` - @page { margin-top: ${effectivePaddingY}pt; } - @page :first { margin-top: 0; } - `; -} diff --git a/src/integrations/orpc/services/printer.ts b/src/integrations/orpc/services/printer.ts index 7c699bfc1..75986ced1 100644 --- a/src/integrations/orpc/services/printer.ts +++ b/src/integrations/orpc/services/printer.ts @@ -12,7 +12,6 @@ import { printMarginTemplates } from "@/schema/templates"; import { env } from "@/utils/env"; import { generatePrinterToken } from "@/utils/printer-token"; -import { getSubsequentPageTopMarginStyle } from "./printer-styles"; import { getStorageService, uploadFile } from "./storage"; const SCREENSHOT_TTL = 1000 * 60 * 60 * 6; // 6 hours @@ -196,17 +195,10 @@ async function doPrintResumeAsPDF( ), ); - const subsequentPageTopMarginStyle = getSubsequentPageTopMarginStyle(pagePaddingY, data.metadata.page.marginY); - // Step 5a: Prepare the DOM for PDF rendering (background colors, reset margins, print padding) await page .evaluate( - ( - pagePaddingX: number, - pagePaddingY: number, - subsequentPageTopMarginStyle: string | null, - backgroundColor: string, - ) => { + (pagePaddingX: number, pagePaddingY: number, backgroundColor: string) => { const root = document.documentElement; const body = document.body; const pageElements = document.querySelectorAll("[data-page-index]"); @@ -249,18 +241,9 @@ async function doPrintResumeAsPDF( } } } - - // Add top margin to PDF pages 2+ so content doesn't start flush at the top. - // The html/body background colors above ensure the margin area is colored. - if (subsequentPageTopMarginStyle) { - const style = document.createElement("style"); - style.textContent = subsequentPageTopMarginStyle; - document.head.appendChild(style); - } }, pagePaddingX, pagePaddingY, - subsequentPageTopMarginStyle, data.metadata.design.colors.background, ) .catch((error) =>