Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I apply styles like color, table CSS for jsPDF?

Tags:

jspdf

I'm new to using jsPDF, am able to generate normal PDF fine, but when am trying to apply external CSS or normal style background color its does not have any effect.

My JSP includes are:

<script  src="Javascript/external/jspdf.js"></script>
<script  src="Javascript/external/jspdf.plugin.standard_fonts_metrics.js"></script> 
<script  src="Javascript/external/jspdf.plugin.split_text_to_size.js"></script>               
<script  src="Javascript/external/jspdf.plugin.from_html.js"></script>
<script src="Javascript/external/jspdf.debug.js"></script>

I am using the script below to generate HTML.

like image 952
user2126181 Avatar asked Jun 06 '14 07:06

user2126181


1 Answers

Set Font Size

var doc = new jsPDF();
doc.setFontSize(22);
doc.text(20, 20, 'This is a title');

Set Font Type

 doc.setFont("times");
 doc.setFontType("italic");
 doc.text(20, 40, 'This is times italic.');

Set font Color

 doc.setTextColor(255,0,0);
 doc.text(20, 40, 'This is red.');
like image 85
hari Avatar answered Sep 21 '22 18:09

hari