index.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
<!DOCTYPE html> <html> <head> <title>JSPDF Watermark Example</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.min.js"></script> </head> <body> <button onclick="generatePDF()">Generate PDF</button> <script> function generatePDF() { const doc = new jsPDF(); // Watermark properties const watermarkText = "coding shiksha"; const watermarkFontSize = 50; // Get page dimensions const pageWidth = doc.internal.pageSize.getWidth(); const pageHeight = doc.internal.pageSize.getHeight(); // Set the text properties (simulated opacity with a lighter color) doc.setFontSize(watermarkFontSize); doc.setTextColor(200, 200, 200); // Light grey (to simulate transparency) // Add rotated text as watermark doc.text(watermarkText, pageWidth / 2, pageHeight / 2, { align: "center", angle: 45 }); // Save the PDF doc.save("watermark.pdf"); } </script> </body> </html> |