Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.
TypeScript ai-agentai-resume-analyzerapplication-trackerapplication-tracking-systematscareerjob-applicationjob-automationjob-huntingjob-searchjob-seeker-toolsjob-trackerjob-trackingjobsearchjobseekersmcpollamaresumeresume-reviewself-hosted
feat(resume-pdf): add "Page n of N" to the bottom right of multi-page resume exports, with a Footer toggle in the export settings that is on by default and hidden for one-page resumes; report the preview's page count from the shared preview pane
Khuram Niazfd4e67da0c3c
diff --git a/__tests__/ExportSettingsPanel.spec.tsx b/__tests__/ExportSettingsPanel.spec.tsxindex 4cd99c2..b58fea0 100644--- a/__tests__/ExportSettingsPanel.spec.tsx+++ b/__tests__/ExportSettingsPanel.spec.tsx@@ -185,6 +185,37 @@ describe("ExportSettingsPanel — stepper buttons", () => {});});+describe("ExportSettingsPanel — footer", () => {+ it("shows page numbers by default and turns them off on uncheck", async () => {+ const { onChange, user } = renderPanel();+ const toggle = screen.getByRole("switch", { name: "Show page numbers" });++ expect(toggle).toBeChecked();+ await user.click(toggle);++ expect(onChange).toHaveBeenLastCalledWith({+ ...defaultResumeExportSettings,+ showPageNumbers: false,+ });+ });+});++describe("ExportSettingsPanel — footer, single page", () => {+ it("hides the footer group when the resume is one page", () => {+ render(+ <ExportSettingsPanel+ settings={defaultResumeExportSettings}+ onChange={vi.fn()}+ singlePage+ />,+ );+ expect(screen.queryByRole("button", { name: /Footer/ })).toBeNull();+ expect(+ screen.queryByRole("switch", { name: "Show page numbers" }),+ ).toBeNull();+ });+});+describe("ExportSettingsPanel — typing", () => {it("commits a typed value that is in range", async () => {const { onChange, user } = renderPanel();diff --git a/__tests__/resumeExportSettings.spec.ts b/__tests__/resumeExportSettings.spec.tsindex f68ef76..76cbb1c 100644--- a/__tests__/resumeExportSettings.spec.ts+++ b/__tests__/resumeExportSettings.spec.ts@@ -24,6 +24,7 @@ describe("defaultResumeExportSettings", () => {marginHorizontal: 48,sectionSpacing: 6,entrySpacing: 8,+ showPageNumbers: true,});});@@ -37,6 +38,7 @@ describe("defaultResumeExportSettings", () => {"marginHorizontal","sectionSpacing","entrySpacing",+ "showPageNumbers",]);});diff --git a/__tests__/useResumeExportSettings.spec.tsx b/__tests__/useResumeExportSettings.spec.tsxindex 199def4..d2f94d3 100644--- a/__tests__/useResumeExportSettings.spec.tsx+++ b/__tests__/useResumeExportSettings.spec.tsx@@ -35,10 +35,20 @@ describe("coerceResumeExportSettings", () => {marginHorizontal: 36,sectionSpacing: 14,entrySpacing: 10,+ showPageNumbers: false,};expect(coerceResumeExportSettings(stored)).toEqual(stored);});+ // Settings saved before the footer existed have no showPageNumbers key.+ it("turns page numbers on unless a boolean says otherwise", () => {+ for (const value of [undefined, "false", 0, null]) {+ expect(+ coerceResumeExportSettings({ showPageNumbers: value }).showPageNumbers,+ ).toBe(true);+ }+ });+// A key written by an older build, or edited by hand, must never reach a// style sheet as an unknown token.it("drops a named value that is not one of its setting's options", () => {@@ -147,6 +157,28 @@ describe("useResumeExportSettings", () => {);});+ it("keeps page numbers off across a template change", () => {+ const { result } = renderHook(() => useResumeExportSettings(true));++ act(() => {+ result.current.setSettings({+ ...defaultResumeExportSettings,+ showPageNumbers: false,+ });+ });+ act(() => {+ result.current.setSettings({+ ...result.current.settings,+ template: "professional",+ });+ });++ expect(result.current.settings).toEqual({+ ...RESUME_TEMPLATE_DEFAULTS.professional,+ showPageNumbers: false,+ });+ });+it("resets to the current template's defaults, not Simple's", () => {const { result } = renderHook(() => useResumeExportSettings(true));diff --git a/src/components/pdf-export/PdfExportDialog.tsx b/src/components/pdf-export/PdfExportDialog.tsxindex 76fbe37..2f892ca 100644--- a/src/components/pdf-export/PdfExportDialog.tsx+++ b/src/components/pdf-export/PdfExportDialog.tsx@@ -29,6 +29,7 @@ type PdfExportDialogProps = {hasError: boolean;canExport: boolean;settingsPanel: ReactNode;+ onPageCountChange?: (count: number) => void;onExport: (prepared: PreviewResult | null) => void;};@@ -46,6 +47,7 @@ export function PdfExportDialog({hasError,canExport,settingsPanel,+ onPageCountChange,onExport,}: PdfExportDialogProps) {// Exporting mid-generation would download the settings just switched away@@ -73,6 +75,7 @@ export function PdfExportDialog({canExport={canExport}previewLabel={previewLabel}emptyMessage={emptyMessage}+ onPageCountChange={onPageCountChange}className="h-full"/></div>diff --git a/src/components/pdf-export/PdfPreviewPane.tsx b/src/components/pdf-export/PdfPreviewPane.tsxindex d0adf71..180e9dd 100644--- a/src/components/pdf-export/PdfPreviewPane.tsx+++ b/src/components/pdf-export/PdfPreviewPane.tsx@@ -24,6 +24,8 @@ type PdfPreviewPaneProps = {previewLabel: string;/** Shown when canExport is false. */emptyMessage: string;+ /** Must be stable (a state setter): it is an effect dependency. */+ onPageCountChange?: (count: number) => void;className?: string;};@@ -47,6 +49,7 @@ export function PdfPreviewPane({canExport,previewLabel,emptyMessage,+ onPageCountChange,className,}: PdfPreviewPaneProps) {const scrollRef = useRef<HTMLDivElement>(null);@@ -214,6 +217,10 @@ export function PdfPreviewPane({};}, [blob, size, fitMode]);+ useEffect(() => {+ onPageCountChange?.(pageCount);+ }, [pageCount, onPageCountChange]);+const hasPages = pageCount > 0;const showEmpty = !canExport;const showError = canExport && (hasError || renderFailed);diff --git a/src/components/profile/ExportPdfDialog.tsx b/src/components/profile/ExportPdfDialog.tsxindex 9fb3a73..e33d8cd 100644--- a/src/components/profile/ExportPdfDialog.tsx+++ b/src/components/profile/ExportPdfDialog.tsx@@ -1,5 +1,6 @@"use client";+import { useState } from "react";import { PdfExportDialog } from "@/components/pdf-export/PdfExportDialog";import type { Resume } from "@/models/profile.model";import { settingsKey } from "@/models/pdfExport.model";@@ -36,6 +37,9 @@ export function ExportPdfDialog({settingsKey(settings) ===settingsKey(RESUME_TEMPLATE_DEFAULTS[settings.template]);+ // 0 until the preview has drawn, so the toggle is never locked on a guess.+ const [pageCount, setPageCount] = useState(0);+const canExport = canExportResume(resume);const { blob, filename, isGenerating, error } = useResumePdfPreview(resume,@@ -56,6 +60,7 @@ export function ExportPdfDialog({isGenerating={isGenerating}hasError={!!error}canExport={canExport}+ onPageCountChange={setPageCount}onExport={(prepared) => onExport(settings, prepared)}settingsPanel={<ExportSettingsPanel@@ -63,6 +68,7 @@ export function ExportPdfDialog({onChange={setSettings}onReset={reset}isDefault={isDefault}+ singlePage={pageCount === 1}/>}/>diff --git a/src/components/profile/export-pdf-dialog/ExportSettingsPanel.tsx b/src/components/profile/export-pdf-dialog/ExportSettingsPanel.tsxindex 145b62b..95b4c1f 100644--- a/src/components/profile/export-pdf-dialog/ExportSettingsPanel.tsx+++ b/src/components/profile/export-pdf-dialog/ExportSettingsPanel.tsx@@ -3,9 +3,12 @@import { Button } from "@/components/ui/button";import {DisclosureGroup,+ ROW,SelectRow,StepperRow,} from "@/components/pdf-export/settings-rows";+import { Label } from "@/components/ui/label";+import { Switch } from "@/components/ui/switch";import {formatSettingValue,PDF_FONT_LABELS,@@ -21,6 +24,8 @@ type ExportSettingsPanelProps = {onChange: (settings: ResumeExportSettings) => void;onReset?: () => void;isDefault?: boolean;+ // Hides the Footer group: a one-page resume prints no page number.+ singlePage?: boolean;};const ID_PREFIX = "resume-export";@@ -30,6 +35,7 @@ export function ExportSettingsPanel({onChange,onReset,isDefault,+ singlePage,}: ExportSettingsPanelProps) {const setNumber = (field: ResumeNumericSetting) => (value: number) =>onChange({ ...settings, [field]: value });@@ -107,6 +113,31 @@ export function ExportSettingsPanel({/></DisclosureGroup>+ {/* Its only option does nothing on a one-page resume. */}+ {!singlePage && (+ <DisclosureGroup+ title="Footer"+ summary={`Page numbers ${settings.showPageNumbers ? "on" : "off"}`}+ >+ <div className={ROW}>+ <Label+ htmlFor={`${ID_PREFIX}-showPageNumbers`}+ className="cursor-pointer font-normal"+ >+ Show page numbers+ </Label>+ <Switch+ id={`${ID_PREFIX}-showPageNumbers`}+ className="ml-auto"+ checked={settings.showPageNumbers}+ onCheckedChange={(showPageNumbers) =>+ onChange({ ...settings, showPageNumbers })+ }+ />+ </div>+ </DisclosureGroup>+ )}+{onReset && (<div className="flex justify-end"><Buttondiff --git a/src/components/profile/resume-container/useResumeExportSettings.ts b/src/components/profile/resume-container/useResumeExportSettings.tsindex dbefee9..3b8e10e 100644--- a/src/components/profile/resume-container/useResumeExportSettings.ts+++ b/src/components/profile/resume-container/useResumeExportSettings.ts@@ -39,6 +39,10 @@ export function coerceResumeExportSettings(next.font = raw.font as PdfFont;}+ if (typeof raw.showPageNumbers === "boolean") {+ next.showPageNumbers = raw.showPageNumbers;+ }+// Iterates the resume's own field list, never the merged spec table.// clampNumericField returns the passed fallback for anything that is not// a finite number, so a missing key needs no guard.@@ -56,8 +60,9 @@ export function coerceResumeExportSettings(// Reads on open, keeping the resume's own rule on top: picking a template// re-seeds the rest, because each template's defaults are its own shipped// literals and carrying the previous one's numbers across would silently-// restyle the template the user just chose. The letter has no template, so-// this rule stays here rather than moving into the shared hook.+// restyle the template the user just chose. Page numbers are a preference,+// not a template literal, so they carry across. The letter has no template,+// so this rule stays here rather than moving into the shared hook.export function useResumeExportSettings(open: boolean) {const { settings, setSettings, ready } = useExportSettings({storageKey: KEY,@@ -70,7 +75,10 @@ export function useResumeExportSettings(open: boolean) {setSettings(next.template === settings.template? next- : { ...RESUME_TEMPLATE_DEFAULTS[next.template] },+ : {+ ...RESUME_TEMPLATE_DEFAULTS[next.template],+ showPageNumbers: next.showPageNumbers,+ },);return {diff --git a/src/components/profile/resume-pdf/ProfessionalTemplate.tsx b/src/components/profile/resume-pdf/ProfessionalTemplate.tsxindex 3d10121..c3f2cb4 100644--- a/src/components/profile/resume-pdf/ProfessionalTemplate.tsx+++ b/src/components/profile/resume-pdf/ProfessionalTemplate.tsx@@ -75,12 +75,14 @@ type Props = {resume: Resume;htmlNodes: ResumeHtmlNodes;styles: ProfessionalStyles;+ showPageNumbers: boolean;};export function ProfessionalResumeDocument({resume,htmlNodes,styles: s,+ showPageNumbers,}: Props) {const { ContactInfo, ResumeSections } = resume;@@ -316,6 +318,15 @@ export function ProfessionalResumeDocument({</View></View>) : null}+ {showPageNumbers && (+ <Text+ fixed+ style={s.pageNumber}+ render={({ pageNumber, totalPages }) =>+ totalPages > 1 ? `Page ${pageNumber} of ${totalPages}` : ""+ }+ />+ )}</Page></Document>);diff --git a/src/components/profile/resume-pdf/SimpleTemplate.tsx b/src/components/profile/resume-pdf/SimpleTemplate.tsxindex 9d5f1bc..057e6b9 100644--- a/src/components/profile/resume-pdf/SimpleTemplate.tsx+++ b/src/components/profile/resume-pdf/SimpleTemplate.tsx@@ -34,9 +34,15 @@ type Props = {resume: Resume;htmlNodes: ResumeHtmlNodes;styles: SimpleStyles;+ showPageNumbers: boolean;};-export function SimpleResumeDocument({ resume, htmlNodes, styles }: Props) {+export function SimpleResumeDocument({+ resume,+ htmlNodes,+ styles,+ showPageNumbers,+}: Props) {const { ContactInfo, ResumeSections } = resume;const skillsSection = ResumeSections?.find(@@ -205,6 +211,15 @@ export function SimpleResumeDocument({ resume, htmlNodes, styles }: Props) {))}</View>)}+ {showPageNumbers && (+ <Text+ fixed+ style={styles.pageNumber}+ render={({ pageNumber, totalPages }) =>+ totalPages > 1 ? `Page ${pageNumber} of ${totalPages}` : ""+ }+ />+ )}</Page></Document>);diff --git a/src/components/profile/resume-pdf/generateResumePdf.tsx b/src/components/profile/resume-pdf/generateResumePdf.tsxindex 11ad6eb..e475025 100644--- a/src/components/profile/resume-pdf/generateResumePdf.tsx+++ b/src/components/profile/resume-pdf/generateResumePdf.tsx@@ -67,6 +67,7 @@ export async function generateResumePdfBlob(resume={resume}htmlNodes={htmlNodes}styles={styles}+ showPageNumbers={settings.showPageNumbers}/>);} else {@@ -78,6 +79,7 @@ export async function generateResumePdfBlob(resume={resume}htmlNodes={htmlNodes}styles={styles}+ showPageNumbers={settings.showPageNumbers}/>);}diff --git a/src/components/profile/resume-pdf/styles/professional.styles.ts b/src/components/profile/resume-pdf/styles/professional.styles.tsindex 295b2bc..a0b379f 100644--- a/src/components/profile/resume-pdf/styles/professional.styles.ts+++ b/src/components/profile/resume-pdf/styles/professional.styles.ts@@ -1,7 +1,7 @@import { StyleSheet } from "@react-pdf/renderer";import { HtmlStyleSet } from "@/components/pdf-export/types";import type { ResumeExportSettings } from "@/models/resumeExport.model";-import { resumeStyleTokens } from "./tokens";+import { A4_HEIGHT, resumeStyleTokens } from "./tokens";const ACCENT = "#34506e";const NEAR_BLACK = "#1a1a1a";@@ -164,6 +164,18 @@ export function buildProfessionalStyles(settings: ResumeExportSettings) {fontSize: t.pt(10),},link: { color: NEAR_BLACK, textDecoration: "none" },+ // Absolute offsets run from the page edge, not the padding; lineHeight 1+ // keeps the number centred in the bottom margin.+ pageNumber: {+ position: "absolute",+ top: A4_HEIGHT - (t.marginVertical + t.pt(9)) / 2,+ left: t.marginHorizontal,+ right: t.marginHorizontal,+ textAlign: "right",+ fontSize: t.pt(9),+ lineHeight: 1,+ color: GRAY,+ },});const htmlStyles: HtmlStyleSet = {diff --git a/src/components/profile/resume-pdf/styles/simple.styles.ts b/src/components/profile/resume-pdf/styles/simple.styles.tsindex 2c339ab..354a094 100644--- a/src/components/profile/resume-pdf/styles/simple.styles.ts+++ b/src/components/profile/resume-pdf/styles/simple.styles.ts@@ -1,7 +1,7 @@import { StyleSheet } from "@react-pdf/renderer";import { HtmlStyleSet } from "@/components/pdf-export/types";import type { ResumeExportSettings } from "@/models/resumeExport.model";-import { resumeStyleTokens } from "./tokens";+import { A4_HEIGHT, resumeStyleTokens } from "./tokens";export function buildSimpleStyles(settings: ResumeExportSettings) {const t = resumeStyleTokens(settings);@@ -89,6 +89,18 @@ export function buildSimpleStyles(settings: ResumeExportSettings) {entryBlock: { marginBottom: t.entrySpacing },certBlock: { marginBottom: t.certSpacing },link: { color: "#000000", textDecoration: "none" },+ // Absolute offsets run from the page edge, not the padding; lineHeight 1+ // keeps the number centred in the bottom margin.+ pageNumber: {+ position: "absolute",+ top: A4_HEIGHT - (t.marginVertical + t.pt(9)) / 2,+ left: t.marginHorizontal,+ right: t.marginHorizontal,+ textAlign: "right",+ fontSize: t.pt(9),+ lineHeight: 1,+ color: "#444444",+ },});const htmlStyles: HtmlStyleSet = {diff --git a/src/components/profile/resume-pdf/styles/tokens.ts b/src/components/profile/resume-pdf/styles/tokens.tsindex 08143d0..31ae170 100644--- a/src/components/profile/resume-pdf/styles/tokens.ts+++ b/src/components/profile/resume-pdf/styles/tokens.ts@@ -8,6 +8,11 @@ import {// templates (6 against 8), so the ratio is identity at the default.const CERT_SPACING_RATIO = 0.75;+// Both templates render on A4. The page-number footer anchors from the top+// because react-pdf drops an absolute render Text anchored by `bottom` once+// a lineHeight applies to it.+export const A4_HEIGHT = 841.89;+export type StyleTokens = BaseStyleTokens & {sectionSpacing: number;entrySpacing: number;diff --git a/src/models/resumeExport.model.ts b/src/models/resumeExport.model.tsindex 4ef038f..655b9c3 100644--- a/src/models/resumeExport.model.ts+++ b/src/models/resumeExport.model.ts@@ -30,6 +30,7 @@ export interface ResumeExportSettings {marginHorizontal: number;sectionSpacing: number;entrySpacing: number;+ showPageNumbers: boolean;}// Each template's own literals, so building its styles at its own defaults@@ -47,6 +48,7 @@ export const RESUME_TEMPLATE_DEFAULTS: Record<marginHorizontal: 48,sectionSpacing: 6,entrySpacing: 8,+ showPageNumbers: true,},professional: {template: "professional",@@ -57,6 +59,7 @@ export const RESUME_TEMPLATE_DEFAULTS: Record<marginHorizontal: 44,sectionSpacing: 12,entrySpacing: 8,+ showPageNumbers: true,},};