Skip to content
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

Merged
merged 79 commits into from Mar 15, 2021
Merged

Conversation

Sgkhour
Copy link
Contributor

@Sgkhour Sgkhour commented Jan 10, 2021

[sorry, originally submitted the PR against master not develop and didn't know how to undo this.. so resubmitting against develop]

looping back on the open issue #222 and some code changes i am proposing to address it (in line with #262 by David Moore). code is meant to fix some missing offset to line up headers and table spacing on every page. code can benefit from some refactoring but just tested it in 2.3.3 and looks good .

account for space.header and space.footer in page margins calculations
if table has a header that repeats on everypage, make sure the cells are shifted by headerHeight and adjust the position of the size wrt minOffset. also add table padding to the surrounding cells
headerShift = false
}
//add table padding around cells
nextPageCells = shiftCellsBy(cells: nextPageCells, shiftValue: table.padding)
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

@@ -450,7 +461,22 @@ internal class PDFTableObject: PDFRenderObject {
}
return result
}


internal typealias ShiftedCells = ([PDFTableCalculatedCell])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
internal typealias ShiftedCells = ([PDFTableCalculatedCell])
internal typealias ShiftedCells = [PDFTableCalculatedCell]

It is not necessary to wrap the array in parantheses and that might lead to side effects (it would be a single value tuple)

@@ -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
Copy link
Member

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 or shouldSplitCellsOnPageBreak?

Sgkhour and others added 17 commits January 22, 2021 23:31
fixed the spacing between the first row and the table header on rest of the pages (after firstpage)
fixed the PDFTableObject test
adjust the offset in TableObjectSpec test
code cleanup as per @philprime

Co-Authored-By: Philip Niedertscheider <dev@philpri.me>
adjusted the expected value of the teableobkect test

Co-Authored-By: Philip Niedertscheider <dev@philpri.me>
@codecov
Copy link

codecov bot commented Mar 1, 2021

Codecov Report

Merging #264 (dbaa0e1) into develop (f994081) will increase coverage by 0.70%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #264      +/-   ##
===========================================
+ Coverage    56.77%   57.48%   +0.70%     
===========================================
  Files          122      122              
  Lines         4329     4311      -18     
===========================================
+ Hits          2458     2478      +20     
+ Misses        1871     1833      -38     
Impacted Files Coverage Δ
Source/Internal/Graphics/PDFContext.swift 81.25% <ø> (-0.65%) ⬇️
Source/Internal/Table/PDFTableObject.swift 89.27% <100.00%> (+10.34%) ⬆️
Source/Internal/Utils/PDFCalculations.swift 44.40% <100.00%> (-2.86%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f994081...dbaa0e1. Read the comment docs.

merged with docs directory which i shouldn't :(  so removing it from my fork
@philprime philprime merged commit 0d49378 into techprimate:develop Mar 15, 2021
philprime pushed a commit that referenced this pull request Aug 26, 2021
* Update PDFCalculations.swift
account for space.header and space.footer in page margins calculations
* Update PDFTableObject.swift
- if table has a header that repeats on everypage, make sure the cells are shifted by headerHeight and adjust the position of the size wrt minOffset. also add table padding to the surrounding cells
- fixed the spacing between the first row and the table header on rest of the pages (after firstpage)
* Update PDFTableObjectSpec.swift
Co-authored-by: Philip Niedertscheider <dev@philpri.me>
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.

None yet

3 participants