Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -61,6 +63,49 @@ const doc = new jsPDF();

doc.text("Hello world!", 10, 10);
doc.save("a4.pdf");

```
#### Adding Styled Text (Bold / Color)

```javascript
// -------------------------------------------------------

// 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-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:
Expand Down