如何在 JSPDF 中为 pdf.cell 应用 css
How to apply css for pdf.cell in JSPDF
我有一个需求,我需要生成一个由 table 组成的 PDF 文件。
我能够生成PDF。但是,我想将样式应用于边框。当前边框显示为黑色。我想将颜色更改为白色。我该怎么做??
这是我的 js 函数,当 "Export to PDF" link 被点击时被调用。
为了 tableId
,我传递了我的 table 名字。
我的table如图:
我生成的PDF如图:
我想将生成的 PDF 的边框颜色更改为 "grey"。我该怎么做?谁能帮我解决这个问题?
在调用 cell()
方法之前,您必须设置 drawColor
属性.
要设置绘图颜色,请使用 setDrawColor
方法
setDrawColor(R,G,B);
有关此方法的更多详细信息,请参见 API 文档。
http://rawgit.com/MrRio/jsPDF/master/docs/global.html#setDrawColor
通过将 RGB 值设置为
setDrawColor(0);
示例:
//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)
检查此 fiddle 以供参考:https://jsfiddle.net/Purushoth/x4xo4owj/
请查看jsPDF-Autotable plugin which has lot of built-in features for custom styling https://simonbengtsson.github.io/jsPDF-AutoTable/#header-footer。
我有一个需求,我需要生成一个由 table 组成的 PDF 文件。 我能够生成PDF。但是,我想将样式应用于边框。当前边框显示为黑色。我想将颜色更改为白色。我该怎么做??
这是我的 js 函数,当 "Export to PDF" link 被点击时被调用。
为了 tableId
,我传递了我的 table 名字。
我的table如图:
我生成的PDF如图:
我想将生成的 PDF 的边框颜色更改为 "grey"。我该怎么做?谁能帮我解决这个问题?
在调用 cell()
方法之前,您必须设置 drawColor
属性.
要设置绘图颜色,请使用 setDrawColor
方法
setDrawColor(R,G,B);
有关此方法的更多详细信息,请参见 API 文档。 http://rawgit.com/MrRio/jsPDF/master/docs/global.html#setDrawColor
通过将 RGB 值设置为
setDrawColor(0);
示例:
//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)
检查此 fiddle 以供参考:https://jsfiddle.net/Purushoth/x4xo4owj/
请查看jsPDF-Autotable plugin which has lot of built-in features for custom styling https://simonbengtsson.github.io/jsPDF-AutoTable/#header-footer。