Skip to content

Fix: Ensure consistent line rendering for cell borders#1093

Closed
simonbengtsson wants to merge 1 commit intomainfrom
fix/footer-linewidth-consistency
Closed

Fix: Ensure consistent line rendering for cell borders#1093
simonbengtsson wants to merge 1 commit intomainfrom
fix/footer-linewidth-consistency

Conversation

@simonbengtsson
Copy link
Copy Markdown
Owner

The issue reported that footer line widths were not appearing the same as header line widths, even when configured with the same numerical lineWidth value (e.g., 2) and color.

This was likely due to the jsPDF draw color state not being explicitly re-applied immediately before drawing each border segment within the drawCellBorders function. While lineWidth was set, the lineColor relied on an earlier applyStyles call, which could lead to inconsistencies if the state changed.

This commit modifies the drawLine helper function within drawCellBorders in src/tableDrawer.ts to:

  1. Accept cell.styles.lineColor as a parameter.
  2. Explicitly call jsPDFDoc.setDrawColor() with this color immediately before jsPDFDoc.setLineWidth() and the jsPDFDoc.line() command.

This ensures that both line width and line color are correctly set in the jsPDF graphics state for each border segment (top, bottom, left, right) for all cells, improving rendering consistency across table sections (head, body, foot).

The issue reported that footer line widths were not appearing the same
as header line widths, even when configured with the same numerical
lineWidth value (e.g., 2) and color.

This was likely due to the jsPDF draw color state not being explicitly
re-applied immediately before drawing each border segment within the
`drawCellBorders` function. While `lineWidth` was set, the `lineColor`
relied on an earlier `applyStyles` call, which could lead to
inconsistencies if the state changed.

This commit modifies the `drawLine` helper function within
`drawCellBorders` in `src/tableDrawer.ts` to:
1. Accept `cell.styles.lineColor` as a parameter.
2. Explicitly call `jsPDFDoc.setDrawColor()` with this color
   immediately before `jsPDFDoc.setLineWidth()` and the
   `jsPDFDoc.line()` command.

This ensures that both line width and line color are correctly
set in the jsPDF graphics state for each border segment (top, bottom,
left, right) for all cells, improving rendering consistency across
table sections (head, body, foot).
@merlinchen
Copy link
Copy Markdown

Will this commit be merged to master?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants