From 725041802b95c18c5b3bf0f1ed0a337646a34f11 Mon Sep 17 00:00:00 2001 From: rajderks <2419711+rajderks@users.noreply.github.com> Date: Tue, 12 Dec 2017 09:58:29 +0100 Subject: [PATCH] Table width rendering bug The table width was properly calculated, but not assigned to the drawing rectangle. I thus propose the above change. Also short-handed the reducer. --- SimplePDF/SimplePDF.swift | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/SimplePDF/SimplePDF.swift b/SimplePDF/SimplePDF.swift index 1677bf8..a53d6e9 100644 --- a/SimplePDF/SimplePDF.swift +++ b/SimplePDF/SimplePDF.swift @@ -303,16 +303,9 @@ open class SimplePDF { let height = (CGFloat(rowCount)*rowHeight) - let drawRect = CGRect(x: currentOffset.x, y: currentOffset.y, width: pageBounds.width - pageMarginLeft - pageMarginRight, height: height) - - UIColor.black.setStroke() - UIColor.black.setFill() - let tableWidth = { () -> CGFloat in if let cws = tableDefinition?.columnWidths { - return cws.reduce(0, { (result, current) -> CGFloat in - return result + current - }) + return cws.reduce(0, +) } else if let cw = columnWidth { return CGFloat(columnCount) * cw } @@ -320,6 +313,11 @@ open class SimplePDF { return 0 // default which should never be use, because either columnWidth, or columnsWidths is set }() + let drawRect = CGRect(x: currentOffset.x, y: currentOffset.y, width: tableWidth, height: height) + + UIColor.black.setStroke() + UIColor.black.setFill() + for i in 0...rowCount { let newOrigin = drawRect.origin.y + rowHeight*CGFloat(i)