I have a requirement Where I need to generate a PDF file which consists of table. I am able to generate PDF. But, I want to apply styles to border. Currently the border is showing black in color. I want to change the color to white. Ho do I do that??
Here is my js function which is called when "Export to PDF" link is clicked.
For tableId
I am passing my table name.
My table is as shown:
My PDF Generated is as shown:
I want to change the border color of my generate PDF to "grey". How am I supposed to do that? Can anyone please help me with this?
Before calling cell()
method you have to set drawColor
property.
To set draw color use setDrawColor
method
setDrawColor(R,G,B);
More details about this method are here in the API documentation. http://rawgit.com/MrRio/jsPDF/master/docs/global.html#setDrawColor
The draw color can be reset to black by setting the RGB value to setDrawColor(0);
Example:
//Set text color
doc.setTextColor(0);
doc.text(10, 10, 'This is a test');
//Change text color
doc.setTextColor("#42d254");
//Set draw color
doc.setDrawColor(150,150,150);
doc.cell(40, 40, 50, 20, "cell"); //cell(x,y,w,h,text,i)
Check this fiddle for reference: https://jsfiddle.net/Purushoth/x4xo4owj/
Please checkout jsPDF-Autotable plugin which has lot of built-in features for custom stylinghttps://simonbengtsson.github.io/jsPDF-AutoTable/#header-footer .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.