jsPDF-AutoTable
jsPDF-AutoTable copied to clipboard
horizontalPageBreakRepeat column page break is going to last page, should happen in the next page.
#horizontalPageBreakRepeat
When there is column is break, the breaking other columns suppose to come in the next page but it's going to the last page. When we have more than 200 rows column should break and come in the next page, that's how it should be then only it will be easy to refer the column in the next page.
Please check the demo. https://codepen.io/hari-designer/pen/OJdQrLx?editors=1010
That would make sense to me. Possibly introduced as an option instead of by default to keep backwards compatibility.
I've noticed the plugin is still not working all that well with both footers and Horizontal Page.
Take a look, for instance, on the following two examples, copied from the usual examples, sligthly changed to use both options of horizontalPageBreakBehaviour and footers:
Using horizontalPageBreakBehaviour = 'afterAllRows', which is the default unchanged behaviour
var head = headRows()
head[0].region = 'Region'
head[0].country = 'Country'
head[0].zipcode = 'Zipcode'
head[0].phone = 'Phone'
head[0].datetime = 'DateTime'
head[0].text = 'Text'
var body = bodyRows(50)
body.forEach(function (row) {
row['text'] = faker.lorem.sentence(10)
row['zipcode'] = faker.address.zipCode()
row['country'] = faker.address.country()
row['region'] = faker.address.state()
row['phone'] = faker.phone.phoneNumber()
row['datetime'] = faker.date.recent()
})
doc.text('Split columns across pages if not fit in a single page, showing all the columns first', 14, 20)
doc.autoTable({
head: head,
body: body,
foot: head, // FOOTER WAS ADDED
foot: head,
startY: 25,
// split overflowing columns into pages
horizontalPageBreak: true,
horizontalPageBreakBehaviour: 'afterAllRows',
// repeat this column in split pages
})
return doc
We get the following result document_horizontalPageBreakBehaviour_afterAllRows.pdf
Using horizontalPageBreakBehaviour = 'immediately', which is the new behaviour
var head = headRows()
head[0].region = 'Region'
head[0].country = 'Country'
head[0].zipcode = 'Zipcode'
head[0].phone = 'Phone'
head[0].datetime = 'DateTime'
head[0].text = 'Text'
var body = bodyRows(50)
body.forEach(function (row) {
row['text'] = faker.lorem.sentence(10)
row['zipcode'] = faker.address.zipCode()
row['country'] = faker.address.country()
row['region'] = faker.address.state()
row['phone'] = faker.phone.phoneNumber()
row['datetime'] = faker.date.recent()
})
doc.text('Split columns across pages if not fit in a single page, showing all the columns first', 14, 20)
doc.autoTable({
head: head,
body: body,
foot: head, // FOOTER WAS ADDED
foot: head,
startY: 25,
// split overflowing columns into pages
horizontalPageBreak: true,
horizontalPageBreakBehaviour: 'immediately',
// repeat this column in split pages
})
return doc
We get the following result
document_horizontalPageBreakBehaviour_imediatelly.pdf
As we can see, the footer gets printed twice when the page breaks horizontally. This is because of the following reason. The function printTableWithHorizontalPageBreak iterates the columns/rows making every horizontal page break, by calling the function addPage (lines 100, 120 and 140), and then calling the function printFoot accordingly (lines 107, 131 and 151). However addPage already checks to see wheter to print the footer, and when it does we get the repetiion. I've attempted to address this issue by suppressing the footer on addPage, which is supposed to happend only this time. See the pull request 1013
Should I open a new issue for that?