
jsPDF Tutorial to Set the Opacity of Text Color inside PDF Document in Browser Using Javascript.
You can use setGState() to set opacity before drawing text, like this:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.2.3/jspdf.plugin.autotable.min.js"></script>
<script>
function demoPDF() {
let doc = new jsPDF()
doc.saveGraphicsState();
doc.setGState(new doc.GState({opacity: 0.2}));
doc.text("SIR JOHN WILLIAMSON LATHAM IS THE CAPTAIN OF NEW ZEALAND", x, y, {align: 'center', baseline: 'middle'})
doc.restoreGraphicsState();
doc.save("output.pdf");
};
demoPDF();
</script>If you have been searching for the right note-taking or knowledge management app, you have…
Looking for AnyType alternatives? You're not alone. AnyType has gained popularity as a privacy-focused, local-first…
Notion is a popular all-in-one workspace, but many users seek alternatives for different needs (free…
Logseq is a beloved tool in the personal knowledge management (PKM) community. It's free, open-source,…
Looking for a Webshare alternative? You're not alone. Webshare is a popular proxy service with…
Docker changed software development forever. It made containers accessible, gave developers a simple workflow, and…