Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions src/tableDrawer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import autoTableText from './autoTableText'
import { addTableBorder, getFillStyle } from './common'
import { LineWidths } from './config'
import { LineWidths, Color } from './config'
import { DocHandler, jsPDFDocument } from './documentHandler'
import { Cell, Column, Pos, Row, Table } from './models'
import { assign } from './polyfills'
Expand Down Expand Up @@ -500,7 +500,7 @@ function drawCellBorders(
if (lineWidth.left) {
x1 -= 0.5 * lineWidth.left
}
drawLine(lineWidth.top, x1, y1, x2, y2)
drawLine(lineWidth.top, x1, y1, x2, y2, cell.styles.lineColor)
}

if (lineWidth.bottom) {
Expand All @@ -514,7 +514,7 @@ function drawCellBorders(
if (lineWidth.left) {
x1 -= 0.5 * lineWidth.left
}
drawLine(lineWidth.bottom, x1, y1, x2, y2)
drawLine(lineWidth.bottom, x1, y1, x2, y2, cell.styles.lineColor)
}

if (lineWidth.left) {
Expand All @@ -528,7 +528,7 @@ function drawCellBorders(
if (lineWidth.bottom) {
y2 += 0.5 * lineWidth.bottom
}
drawLine(lineWidth.left, x1, y1, x2, y2)
drawLine(lineWidth.left, x1, y1, x2, y2, cell.styles.lineColor)
}

if (lineWidth.right) {
Expand All @@ -542,7 +542,7 @@ function drawCellBorders(
if (lineWidth.bottom) {
y2 += 0.5 * lineWidth.bottom
}
drawLine(lineWidth.right, x1, y1, x2, y2)
drawLine(lineWidth.right, x1, y1, x2, y2, cell.styles.lineColor)
}

function drawLine(
Expand All @@ -551,9 +551,18 @@ function drawCellBorders(
y1: number,
x2: number,
y2: number,
lineColor: Color,
) {
doc.getDocument().setLineWidth(width)
doc.getDocument().line(x1, y1, x2, y2, 'S')
const jsPDFDoc = doc.getDocument()
if (typeof lineColor === 'string') {
jsPDFDoc.setDrawColor(lineColor)
} else if (Array.isArray(lineColor)) {
jsPDFDoc.setDrawColor(lineColor[0], lineColor[1], lineColor[2])
} else if (typeof lineColor === 'number') {
jsPDFDoc.setDrawColor(lineColor)
}
jsPDFDoc.setLineWidth(width)
jsPDFDoc.line(x1, y1, x2, y2, 'S')
}
}

Expand Down