Skip to content

Commit

Permalink
docs: restore previous position after logo
Browse files Browse the repository at this point in the history
  • Loading branch information
schoero committed Oct 29, 2023
1 parent bfbb054 commit 390e574
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/how-to-create-a-complete-bill.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Because the coordinate system of a PDF is based on points, SwissQRBill provides
import { mm2pt } from "swissqrbill/utils";
```

We use the [translate](http://pdfkit.org/docs/vector.html#transformations) method of `PDFDocument` to position the logo 2cm from the left side and 14mm from the top. Then we fill the path with our colors.
We use the [`translate()`](http://pdfkit.org/docs/vector.html#transformations) method of `PDFDocument` to position the logo 2cm from the left side and 14mm from the top. Then we fill the path with our colors. The `save()` and `restore()` methods are used to save the previous coordinates and restore them after the logo is rendered. This way we can change the positioning of the logo without affecting the rest of the document.

#### Adding the addresses

Expand Down
2 changes: 2 additions & 0 deletions examples/how-to-create-a-complete-bill/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const data = {
};

// Add logo
pdf.save();
pdf.translate(mm2pt(20), mm2pt(14));
pdf.path(logoBackground, mm2pt(20), mm2pt(14))
.fillColor("#EA5151")
Expand All @@ -49,6 +50,7 @@ pdf.path(logo, mm2pt(20), mm2pt(14))
pdf.path(logoText, mm2pt(20), mm2pt(14))
.fillColor("#454141")
.fill();
pdf.restore();

// Add creditor address
pdf.fontSize(12);
Expand Down

0 comments on commit 390e574

Please sign in to comment.