mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-11 05:24:59 +10:00
chore: remove getSubsequentPageTopMarginStyle
This commit is contained in:
@@ -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();
|
||||
});
|
||||
});
|
||||
@@ -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; }
|
||||
`;
|
||||
}
|
||||
@@ -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) =>
|
||||
|
||||
Reference in New Issue
Block a user