jsPDF-AutoTable icon indicating copy to clipboard operation
jsPDF-AutoTable copied to clipboard

Cant get RowSpan to work properly with v3.5.15 - affecting page breaks

Open RipleWare opened this issue 4 years ago • 14 comments

Hello, I am trying to export my table which has the first two columns with rows that span across 3-4 pages long at times. So sometimes the rowspan can equal 300+. I am finding that the PDF will print the first row of the table on the first page, and then split off to remaining pages. It is also dropping the border lines for these columns. I have set rowPageBreak: 'avoid' but it doesn't seem to make any difference.

I can't seem to find any resolution to this, as all documentation states that v3 addresses these issues. Would really appreciate some help on this.

Cheers

RipleWare avatar Jul 13 '21 13:07 RipleWare

Sounds like a bug. Can you post a minimal example of the issue?

simonbengtsson avatar Jul 13 '21 21:07 simonbengtsson

Thanks for the reply. Okay, I'll post some screen captures so you can see what I mean (sensitive info blacked out)...

image

My code so far looks like so:

autoTable( doc, {
	html: 'table',
	theme: 'grid',
	//pageBreak: 'auto',
	rowPageBreak: 'avoid',
	startY: 120,
	margin: { top: 10, right: 10, bottom: 10, left: 10 },
	styles: {
		font: 'helvetica',
		//overflow: 'normal',
		fontSize: 6,
		valign: 'middle'
	},
	headStyles: { fillColor: [255, 255, 255], textColor: [0, 0, 0, 0.6], fontStyle: 'bold', fontSize: 5 },
	didParseCell(data) {
		console.log(data);

		// Convert Header cells to uppercase
		if( data.cell.section === 'head' ) {
			data.cell.text = data.cell.text.toString().toUpperCase();
		}

		// Handle top alignment
		if( data.cell.raw.className.toString().includes( 'align-text-top' ) ) {
			data.cell.styles.valign = 'top';
		}

		// Handle center alignment
		if( data.cell.raw.className.toString().includes( 'text-center' ) ) {
			data.cell.styles.halign = 'center';
		}

		// Handle Subtotal Rows
		if( data.cell.raw.parentElement.className === 'subtotalRow' ) {
			data.cell.styles.textColor = '#000';
			data.cell.styles.fillColor = '#EEE';
			data.cell.styles.fontStyle = 'bold';
		}

		//Handle Client text
		if( data.column.index < 2 ) {
			//data.cell.text[1] === '<strong>' + data.cell.text[1] + '</strong>';
		}
	}
})

The example actually pushed out to more pages than shown as Column 1 spans about 300 odd rows, but as you can see, it only adds the first record on the first page and then continues on from page 2. It also drops the RHS border which isn't ideal.

I have tried pageBreak, rowBreak and overflow but nothing seems to make a difference.

Let me know if you need any other data/examples.

Cheers

RipleWare avatar Jul 14 '21 02:07 RipleWare

Thanks. Seems like a clear bug. I'll tag it with the bug label 👌

simonbengtsson avatar Jul 14 '21 08:07 simonbengtsson

I have exactly the same error. Would love to hear, when you found a fix! :) I even get an error message: jspdf.plugin.autotable.js:1255 The content of row 0 will not be drawn correctly since drawing rows with a height larger than the page height and has cells with rowspans is not supported.

I understand the problem, that the height is bigger than the page-height. But the expected behaviour imo would be, to simply "split" the cell and display them on both pages

Gykonik avatar Jul 20 '21 12:07 Gykonik

Hey @simonbengtsson .... just wanted to checkin and see if you had a approximate ETA on a fix for this? I understand you're probably busy, I just wanted to know roughly whether to wait for a fix or try and find some kind of work around, as I am wanting to deliver this report into production soon.

Cheers mate.

RipleWare avatar Jul 29 '21 12:07 RipleWare

As far as I know there is no one working on this actively right now @RipleWare

simonbengtsson avatar Jul 29 '21 12:07 simonbengtsson

I have the same issue. Is there a work around?

odeyal0 avatar Sep 26 '22 13:09 odeyal0

I have the same issue. Is there a work around?

WangZiHao752 avatar Apr 28 '23 11:04 WangZiHao752

image

I have the exactly issue like this. anybody know, how to fix this?

cacing69 avatar Jun 28 '23 02:06 cacing69

I have same issue with this, any update on the fix ?

ngobinh105 avatar Oct 03 '23 12:10 ngobinh105

Currently, rawSpan pageBreak isn't supported, this will change in v4, for now make sure rowSpans don't span multiple pages.

mmghv avatar Oct 08 '23 07:10 mmghv

@trung37 Hello, I used the version you fixed and still had some minor problems; As shown in the following picture

表格合并问题

insist2020 avatar Feb 21 '24 01:02 insist2020