Skip to content

Invoice PDF: a long description in the first row of a page runs into the Rate column #246

Closed

Description

@anurag629

Download PDF in the invoice generator wraps the first line item on each page as if it were in the column header font.

drawTableHead (lib/invoice-pdf.ts, lines 188 to 204) sets 8.5pt bold for the column titles (lines 193 and 194). The row loop then wraps the description with doc.splitTextToSize (line 214) and only afterwards switches to 10.5pt normal (lines 215 and 216). So the first row is measured at 8.5pt and drawn at 10.5pt. Later rows look fine only because the row before them left the font at 10.5pt. The first row after a page break has the same problem, because drawTableHead() runs again there (line 212).

To see it, Load example, give rows 1 and 2 the description Monthly retainer for backend development, code reviews and production support (June 2026), set row 1's rate to 12500, and Download PDF. Measured with the bundled Noto Sans:

  • Row 2 wraps before "reviews", and its first line is 241.7pt wide (the column is 258pt).
  • Row 1 keeps "reviews" on its first line, which is 281.9pt wide at 10.5pt. It ends at x=335.9, and "$12,500.00" starts at x=328.3, so they overlap.

What to do

  • Set the row font (setFont(FONT, "normal"), setFontSize(10.5) and setTextColor) before the splitTextToSize call at line 214, not after it.
  • There are no tests for the PDF yet. One way is vi.mock("jspdf") with a small fake that records the font size each time splitTextToSize is called, then check that every description is measured at 10.5.

Where to look

  • lib/invoice-pdf.ts: drawTableHead (lines 188 to 204) and the row loop (lines 208 to 222)

Acceptance criteria

  • Every description, including the first row on each page, is wrapped at 10.5pt normal
  • With the example above, row 1 wraps before "reviews" like row 2
  • A test that fails on the current code
  • npm run lint, npm run test and npm run build pass

Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off develop, and open your PR against develop with Closes #246 in the description.

Activity

  1. rahul05ranjan commented on Oct 22, 2026

    @rahul05ranjan
    Contributor

    Hi @anurag629, now that #260 is merged I'd like to take this one. Plan, following the issue: in invoice-pdf.ts's row loop, set the 10.5pt normal row font before doc.splitTextToSize(...) so the description is measured with the font it is drawn with — including the first row after drawTableHead() re-sets 8.5pt bold at a page break. I'll add a vitest with a vi.mock("jspdf") fake that records the active font size at each splitTextToSize call and assert every description is measured at 10.5 (it fails on current develop, where the first row is measured at 8.5). Open the PR against develop with Closes #246.

  2. bhushan4work commented on Oct 22, 2026

    @bhushan4work
    Collaborator

    @anurag629 I'd like to work on this issue if its available

  3. anurag629 commented on Oct 22, 2026

    @anurag629
    MemberAuthor

    Hey @bhushan4work, go for it! It's yours, as your second next to ogcops #72. Let me know if you have any questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomershacktoberfestGood pick for Hacktoberfest contributors

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions