-
-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
another fix for showHeaderOnEveryPage #264
Changes from 2 commits
f756e5a
bfee891
d17548a
bf9b18a
17dc161
ecba679
ba6a78f
e2013e4
34a39cb
8ac72eb
739fbc2
2fc8b88
f0c9a6b
91e64b4
99d5598
c84be40
ed1213b
e2dd206
c3244c1
69551cc
b629679
537b656
b0e7404
7fed85c
930481f
8f97c81
2b34637
ce5a417
28c9f01
1069ff3
f98bb2e
28701d5
fc70bf9
a6fc3a1
dfd307a
be59409
c0ce4b9
f9e3c28
f96b001
74a4fee
910f475
437b823
13011a4
3122574
b26dba4
adb6e74
533810a
ac6bc3b
8ab0b1f
84c14bc
6fd3f53
9ad0e78
e733307
0bb8ecd
a788b3d
55fac1c
2c6d6aa
53453df
50d8d47
736f9ba
c1afb59
c3e12ed
85245e8
c90a89e
8f10b3f
fa144dd
652ba1e
ae52122
f888982
283259b
3bde7f8
342bc97
c0bc151
b0daf0a
554ccf5
917c4ed
b35163a
e2d145b
dbaa0e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -284,6 +284,7 @@ internal class PDFTableObject: PDFRenderObject { | |||||
let startPosition: CGPoint = cells.first?.frames.cell.origin ?? .zero | ||||||
var nextPageCells: [PDFTableCalculatedCell] = cells | ||||||
var pageEnd = CGPoint.null | ||||||
var headerShift = true | ||||||
|
||||||
repeat { | ||||||
var pageStart = CGPoint.null | ||||||
|
@@ -296,7 +297,9 @@ internal class PDFTableObject: PDFRenderObject { | |||||
var cellFrame = item.frames.cell | ||||||
var contentFrame = item.frames.content | ||||||
cellFrame.origin.y -= startPosition.y - minOffset | ||||||
cellFrame.origin.y += table.margin | ||||||
contentFrame.origin.y -= startPosition.y - minOffset | ||||||
contentFrame.origin.y += table.margin | ||||||
|
||||||
pageStart = pageStart == .null ? cellFrame.origin : pageStart | ||||||
pageEnd = CGPoint(x: cellFrame.maxX, y: cellFrame.maxY) + CGPoint(x: table.margin, y: table.margin) | ||||||
|
@@ -329,6 +332,15 @@ internal class PDFTableObject: PDFRenderObject { | |||||
} | ||||||
minOffset += headerHeight | ||||||
} | ||||||
if !firstPage { | ||||||
// shift the rest of the cells down by headerHeight | ||||||
if headerShift { | ||||||
nextPageCells = shiftCellsBy(cells: nextPageCells, shiftValue: headerHeight) | ||||||
headerShift = false | ||||||
} | ||||||
//add table padding around cells | ||||||
nextPageCells = shiftCellsBy(cells: nextPageCells, shiftValue: table.padding) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line 342 adds additional spacing for me between the header and the first row on pages > 1. If I comment it out it works fine. |
||||||
} | ||||||
|
||||||
let filterResult = filterCellsOnPage(for: generator, | ||||||
items: nextPageCells, | ||||||
|
@@ -432,7 +444,6 @@ internal class PDFTableObject: PDFRenderObject { | |||||
if shouldSplitCellsOnPageBreak && cellFrame.minY < maxOffset { | ||||||
result.cells.append(item) | ||||||
} | ||||||
// In any case, if the cell does not fit on the active page entirely, it must be repositioned for further pages | ||||||
var nextPageCell = item | ||||||
if shouldSplitCellsOnPageBreak { | ||||||
nextPageCell.frames.cell.origin.y -= contentHeight | ||||||
|
@@ -450,7 +461,22 @@ internal class PDFTableObject: PDFRenderObject { | |||||
} | ||||||
return result | ||||||
} | ||||||
|
||||||
|
||||||
internal typealias ShiftedCells = ([PDFTableCalculatedCell]) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
It is not necessary to wrap the array in parantheses and that might lead to side effects (it would be a single value tuple) |
||||||
|
||||||
internal func shiftCellsBy(cells: [PDFTableCalculatedCell], shiftValue: CGFloat) -> ShiftedCells { | ||||||
var shiftedCells: [PDFTableCalculatedCell] = [] | ||||||
|
||||||
for cell in cells { | ||||||
var shiftedCell = cell | ||||||
|
||||||
shiftedCell.frames.cell.origin.y += shiftValue | ||||||
shiftedCell.frames.content.origin.y += shiftValue | ||||||
shiftedCells.append(shiftedCell) | ||||||
} | ||||||
return shiftedCells | ||||||
} | ||||||
|
||||||
internal func createSliceObject(frame: CGRect, elements: [PDFRenderObject], minOffset: CGFloat, maxOffset: CGFloat) -> PDFSlicedObject { | ||||||
let sliceObject = PDFSlicedObject(children: elements, frame: frame) | ||||||
if frame.maxY > maxOffset { | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be a hardcoded value or should it be connected to
showHeaderOnEveryPage
orshouldSplitCellsOnPageBreak
?