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

Doubled headers and footers heights when using pageBreak: 'avoid' #976

Closed
ocadoret opened this issue Jul 13, 2023 · 0 comments · Fixed by #977 · May be fixed by Faisalginims/pdfexcel#2 or veenone/snipe-it#12
Closed

Doubled headers and footers heights when using pageBreak: 'avoid' #976

ocadoret opened this issue Jul 13, 2023 · 0 comments · Fixed by #977 · May be fixed by Faisalginims/pdfexcel#2 or veenone/snipe-it#12
Labels

Comments

@ocadoret
Copy link
Contributor

When using pageBreak: 'avoid', it seems that headers and footers height are included 2 times in the height determination.

From method drawTable in tableDrawer.js :

  const sectionsHeight =
    table.getHeadHeight(table.columns) + table.getFootHeight(table.columns) // <=== First, here
  let minTableBottomPos = startY + margin.bottom + sectionsHeight

  if (settings.pageBreak === 'avoid') {
    const rows = table.allRows() // <=== Then include a second time here, because allRows includes headers and footers
    const tableHeight = rows.reduce((acc, row) => acc + row.height, 0)

    minTableBottomPos += tableHeight
  }

This results in a faulty computed height when checking if a page break is needed before the table

ocadoret added a commit to ocadoret/jsPDF-AutoTable that referenced this issue Jul 13, 2023
Prevents header and footer heights to be included twice
Fixes simonbengtsson#976
ocadoret added a commit to ocadoret/jsPDF-AutoTable that referenced this issue Jul 13, 2023
Prevents header and footer heights to be included twice
Fixes simonbengtsson#976
simonbengtsson pushed a commit that referenced this issue Jul 13, 2023
Prevents header and footer heights to be included twice
Fixes #976
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment