Skip to content

Commit 30dbe14

Browse files
committed
Clipping Lines to Inside a Rectangle - closes #328
1 parent d7cb062 commit 30dbe14

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

jspdf.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,13 @@ var jsPDF = (function(global) {
10451045
return this.lines([[x2 - x1, y2 - y1]], x1, y1);
10461046
};
10471047

1048+
API.clip = function() {
1049+
// By patrick-roberts, github.com/MrRio/jsPDF/issues/328
1050+
// Call .clip() after calling .rect() with a style argument of null
1051+
out('W') // clip
1052+
out('S') // stroke path; necessary for clip to work
1053+
};
1054+
10481055
/**
10491056
* Adds series of curves (straight lines or cubic bezier curves) to canvas, starting at `x`, `y` coordinates.
10501057
* All data points in `lines` are relative to last line origin.

0 commit comments

Comments
 (0)