diff --git a/README.md b/README.md index f1449e104..c16978750 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,8 @@ out the right file, so importing "jspdf" is enough. Then you're ready to start making your document: +#### Basic Usage Example + ```javascript import { jsPDF } from "jspdf"; @@ -61,6 +63,51 @@ const doc = new jsPDF(); doc.text("Hello world!", 10, 10); doc.save("a4.pdf"); + +``` +#### Adding Styled Text (Bold / Color) + +```javascript +// ------------------------------------------------------- + +import { jsPDF } from "jspdf"; + +// Adding Styled Text (Bold /Color) +const styledDoc = new jsPDF(); + +// Set font to bold +styledDoc.setFont("helvetica", "bold"); +styledDoc.setFontSize(16); +styledDoc.setTextColor(200, 0, 0); // Red color + +styledDoc.text("Hello Hacktoberfest!", 20, 30); +styledDoc.save("styled-text.pdf"); + +``` +#### Adding a Table Example +```javascript +// ------------------------------------------------------- +import { jsPDF } from "jspdf"; +import 'jspdf-autotable'; // Make sure jsPDF AutoTable plugin is installed + +//Adding a Table Example + +const tableDoc = new jsPDF(); +tableDoc.text("My Table Example", 14, 16); + +tableDoc.autoTable({ + head: [['ID', 'Name', 'Age']], + body: [ + [1, 'Alice', 25], + [2, 'Bob', 30], + [3, 'Charlie', 28] + ], + startY: 20, +}); + +tableDoc.save("table-example.pdf"); + + ``` If you want to change the paper size, orientation, or units, you can do: diff --git a/examples/dynamic_charts/dynamic-chart-pdf.html b/examples/dynamic_charts/dynamic-chart-pdf.html new file mode 100644 index 000000000..c1f613006 --- /dev/null +++ b/examples/dynamic_charts/dynamic-chart-pdf.html @@ -0,0 +1,57 @@ + + + + Dynamic Chart PDF Demo + + + + + + + + + +

Weekly Activity Report

+ +
+ + + + +