You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 11, 2020. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 11, 2020. It is now read-only.
Add Support for getLineHeightFactor() and setLineHeightFactor() functions #22
setLineDash() : we use it to set the dash pattern for upcoming lines (line,circle,......)
getLineHeighFactor(): we use it in a function to calculate the text height of many lines text
The next time we merge with master (if this is still feasible), the functions will be added. There is currently no roadmap for this, but it will happen sooner or later.
Here is a patch to add setLineDash() against 3561de8 (current master) which works for me:
diff --git a/jspdf.js b/jspdf.js
index 9a8cc01..7175b77 100644
--- a/jspdf.js+++ b/jspdf.js@@ -3942,6 +3942,33 @@ var jsPDF = (function(global) {
};
/**
+ * Sets the dash pattern for upcoming lines.+ *+ * To reset the settings simply call the method without any parameters.+ * @param {array} dashArray The pattern of the line, expects numbers.+ * @param {number} dashPhase The phase at which the dash pattern starts.+ * @function+ * @instance+ * @returns {jsPDF}+ * @memberOf jsPDF+ * @name setLineDash+ */+ API.setLineDash = function(dashArray, dashPhase) {+ dashArray = dashArray || [];+ dashPhase = dashPhase || 0;++ if (isNaN(dashPhase) || !Array.isArray(dashArray)) {+ throw new Error('Invalid arguments passed to setLineDash.');+ }++ dashArray = dashArray.map(function (x) {return (x * k).toFixed(3)}).join(' ');+ dashPhase = parseFloat((dashPhase * k).toFixed(3));++ out('[' + dashArray + '] ' + dashPhase + ' d');+ return this;+ };++ /**
* Sets the stroke color for upcoming elements.
*
* Depending on the number of arguments given, Gray, RGB, or CMYK
Shall I prepare a pull request?
(I've not included the test cases, because I haven't checked what the new place for them would be. I did slight change the Error message to end with a fullstop and to remove the jsPDF. part.)
The upcoming jsPDF with parallax@849ce007 now already accepts setLineDashPattern() as part of getting more compatible, so implementing setLineDash is not necessary anymore.
Thanks for the hint about setLineDashPattern, I've created a new issue #23.
So remaining here (in this issue) is the support for settting and getting the LineHeightFactor.
@Fadiabb please edit the title to Support getLineHeightFactor() and setLineHeightFactor() next time you are looking into this.
changed the title [-]Add Support for some jspdf functions[/-][+]Add Support for getLineHeightFactor() and setLineHeightFactor() functions[/+]on Dec 3, 2019
Activity
yGuy commentedon Jun 11, 2019
These functions have been added only recently and we will have to merge with the master to get these. What's the use-case for these functions?
Fadiabb commentedon Jun 11, 2019
setLineDash() : we use it to set the dash pattern for upcoming lines (line,circle,......)
getLineHeighFactor(): we use it in a function to calculate the text height of many lines text
yGuy commentedon Jun 11, 2019
The next time we merge with master (if this is still feasible), the functions will be added. There is currently no roadmap for this, but it will happen sooner or later.
bernhardreiter commentedon Jul 2, 2019
Here is a patch to add setLineDash() against 3561de8 (current master) which works for me:
Shall I prepare a pull request?
(I've not included the test cases, because I haven't checked what the new place for them would be. I did slight change the Error message to end with a fullstop and to remove the
jsPDF.part.)HackbrettXXX commentedon Jul 2, 2019
There is already a
setLineDashPatternmethod. We can probably just delegate to it. Also, in "advanced" API mode we should not scale the values byk.bernhardreiter commentedon Jul 3, 2019
The upcoming jsPDF with parallax@849ce007 now already accepts setLineDashPattern() as part of getting more compatible, so implementing setLineDash is not necessary anymore.
bernhardreiter commentedon Jul 3, 2019
Thanks for the hint about setLineDashPattern, I've created a new issue #23.
So remaining here (in this issue) is the support for settting and getting the LineHeightFactor.
@Fadiabb please edit the title to
Support getLineHeightFactor() and setLineHeightFactor()next time you are looking into this.[-]Add Support for some jspdf functions[/-][+]Add Support for getLineHeightFactor() and setLineHeightFactor() functions[/+]