Comments (15)
I think those were older configurations. I went throught the releases, and found the proper way now, is:
doc.autoTable(columns,rows,{
addPageContent:pageContent,
margin: {horizontal:5,top: 20},
startY: 0.47*doc.internal.pageSize.height,
styles: {overflow: 'linebreak'},
columnStyles: {id: {columnWidth: 25}, name:{columnWidth:40}, role: {columnWidth: 15}, location: {columnWidth: 30}}
});
from jspdf-autotable.
Sounds like a good idea and will probably be added at some point! I'm curious about your specific use case though. For now there is a feature to specify overflowColumns
. This is probably the most common use case and when set, it makes all columns fixed width, but the ones specified which will either shrink or grow depending on the width available. An example how to use this option is in the long text
example.
from jspdf-autotable.
My usecase is that i have a table with five columns like:
{title:"ID"}, {title:"Name"}, {title:"Total time"}, {title:"allowed time"},{title:"dif"}
and i want the columns ID,Total time, allowed Time, diff
to have specific widths
this way i have full control of the layout of the table. I think that the behavior of the columns without a width should be sharing the remaining space
from jspdf-autotable.
For instance if i know that ID wont be larger than 50 pt and that way have the rest of the space for the other columns.
Once again thanks for the great plugin :)
from jspdf-autotable.
Thanks! Sounds good, something I will implement. Will write here once it's done.
from jspdf-autotable.
Awesome! Thank you for a great plugin.
from jspdf-autotable.
I have another use case to add to the mix. It might already be there but don't know where as I just found this plugin today.
I have 7 columns with one being the description (which the content will take up a lot of space) and another is the hours (as in Hours worked for a timesheet). The issue is that because the hours is a number that at most will be ##.# (i.e. 10.5), the title only shows "H..." instead of "Hours". I have another field (Job Code) that is similar. Basically, the header text is longer than the data and it is being sized by the data it seems.
For my case, maybe just checking the header text as well for sizing might work.
Anyway, great plugin! So much easier to use than the other libraries I was trying!
from jspdf-autotable.
After reading your comment I realized there was a bug that the header width wasn't calculated correctly. This should now be resolved in version 1.2.4
. Also you should probably set the overflowColumns
property to an array with the description column to only allow that column to shrink or extend it's width. You can check out the long text example for an example how to do this. Let me know if it works for you!
from jspdf-autotable.
Thanks for the quick response. This does fix the header issue for sure. I was already doing the overflowColumns and that worked great for that part but still had the header issue which you have now fixed. I have an issue now where some columns are getting really narrow but even an "overflow" column is giving it the full length. Not sure if it is my issue or not, but the defined width option like this post is about would still help and combined with the "overflowColumns" that you already have in there, it would provide the solution to my needs and provide great flexibility for everyone.
Looking forward to what you do next as everything you have already done works amazing. Fast, easy to use, and looks great right out of the gate. I spent countless hours trying to get other things to work but just couldn't. Great work!
from jspdf-autotable.
Hmm that sounds strange. Feel free to post a new issue with more information if you are still having problems.
Thanks! I also spent many hours searching for a good solution before I figured that the easiest way would probably be to make something myself. I have some interesting things coming up for version 2. Including much easier custom styles, custom column widths, support for more units and easier row and column span.
from jspdf-autotable.
Hi @someatoms have you got a chance to implement @rebizu suggestion on doc.autoTable(
[
{ title : "ID", key : "id" , width: 30} ,
{ title : " Name" , key : "name"}
] , data , {}); ?
from jspdf-autotable.
Support for custom column width is now added (version 1.3). It works just as has been propused in this issue by @rebizu and @reachwasim and there is an example in the long text
example. Let me know if you have any issues with it or other feature request!
from jspdf-autotable.
Hey guys, great job on implementing the column widths, bud could you tell me how many points across is a table in landscape?
Percentages don't work, before someone suggests it :)
from jspdf-autotable.
Hi! An A4 page is 595x842 pt
and minus the default margins the table should be 842-40-40 = 762 pt
wide.
from jspdf-autotable.
Hey Simon, the example link is not working. Can you check it.
Thanks for an amazing plugin!
from jspdf-autotable.
Related Issues (20)
- [Bug] cellPadding not respected for unstyled table HOT 5
- Does anybody created invoice template using this feature? HOT 1
- Ensure table fits in single page regardless of end size HOT 1
- Como puedo cambiar la localizacion de la tabla en el eje x? HOT 2
- you can apply RTL and use Arabic font finally HOT 2
- Rendering html tags as cell content and formatting of cell content HOT 1
- Problem with horizontalPageBreak with colspan column header HOT 1
- Memory is not deallocating for autotable. js heap is increasing eventhough for small amount of data HOT 6
- HTML Entities or HEX Code issues for symbols HOT 5
- line breaks are not working
- Change row colors on page break HOT 1
- jspdf Auto Table, can we break the if the lines are more than 10 HOT 1
- (0 , import_jspdf_autotable.default) is not a function HOT 9
- Textfield Signature?
- 表格项合并时表格项与表头信息不对应 HOT 2
- Multitable loop doesn't align properly and creates unusual gaps or overlaps each other HOT 11
- HorizontalPageBreak page break can continue on same page if vertical space is enough HOT 6
- Cannot Read html tags HOT 1
- Merge Cell Inside the body of the table HOT 1
- Parsing HTML with tables HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jspdf-autotable.