Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set opacity for text color in JSPdf

I am using Jspdf for generate pdf, along with table with multiple records and I want to display watermark text on table but I am not able to set opacity for watermark text color. How to set opacity to the text color in JSpdf in angular

like image 994
Lucky Avatar asked Sep 17 '25 05:09

Lucky


1 Answers

You can use setGState() to set opacity before drawing text, like this:

doc.saveGraphicsState();
doc.setGState(new doc.GState({opacity: 0.2}));
doc.text(text, x, y, {align: 'center', baseline: 'middle'})
doc.restoreGraphicsState();
like image 80
Brian Pursley Avatar answered Sep 19 '25 21:09

Brian Pursley