Open Nervniyak opened 4 years ago
Yes that looks like a bug! Can you post a complete example that reproduces the issue? I know that jspdf have some issues with calculating the width when using justified text for example.
I am using Angular 9 BTW
import * as jsPDF from 'jspdf';
import autoTable, { CellDef } from 'jspdf-autotable';
@Injectable({
providedIn: 'root'
})
export class PdfTableExportService {
public async generateTimeReport(){
const doc = new jsPDF();
const body: CellDef[][] = [];
const head: CellDef[][] = [];
body.push([{
colSpan: 1,
content: '\nLONGUNSPLITTABLETEXTTHATHASNOSPACESATALL',
styles: { cellWidth: 80, cellPadding: 1.5 },
}]);
doc.setFontStyle('normal');
autoTable(doc, {
rowPageBreak: 'avoid',
pageBreak: 'auto',
margin: 10,
head: head,
body: body,
theme: 'grid',
}
doc.save(`pdf.pdf`);
}
}
Result, it broke the line one character later than it should've
Turned out to be a jspdf bug, reported here : https://github.com/parallax/jsPDF/issues/3644
Space-less text overflows the width, like in this example:
If it was a bit longer it would actually break, but with this text
"LONGUNSPLITTABLETEXTTHATHASNOSPACESATALL"
it failed. It seems like the last letter can start printing or padding area.Here's another example S letter overflowed to right padding area here also.![image](https://user-images.githubusercontent.com/34353798/86015240-fa100200-ba29-11ea-9acd-b555bc9ae15f.png)
Style for those cells is pretty simple
The bold label is printed manually and is only represnted by
\n
hereI think this is a bug in lib. Text should not overflow the padding area that much