Romi
Romi

Reputation: 109

JsPDF, jsPDF-AutoTable wrapping row texts needed with overflow hidden

I am trying to create an invoice using jspdf-autotable. I want to address a long address that will wrap properly while maintaining overflow:hidden.

In this fiddle I added

bodyStyles: { valign: "top" }, styles: { overflow: "hidden", cellWidth: "wrap" }, columnStyles: { text: { cellWidth: "auto" } },

which merges the address text with the right table

And in this fiddle I just kept overflow:hidden which keeps the gap between the two adjacent tables but crops the address text.

  1. I want to keep the full address text which will wrap properly while keeping the gap like the 2nd fiddle.
  2. Is is possible to align right where the columns have numerical data? like QTY, Price, Amount?

Upvotes: 2

Views: 4686

Answers (1)

Mohamed Gharib
Mohamed Gharib

Reputation: 2587

If you want the address to wrap probably into multiple line, you need to remove the overflow: "hidden" and the cellWidth: "wrap" styles, "warp" here actually means not to wrap and put it in one line only, so you need to remove both styles, you may also want to set minCellWidth to caption fields.

for question number 2, you can specify right align to specific columns like this columnStyles: {2: {halign: 'right'}, 3: {halign: 'right'}}

Upvotes: 2

Related Questions