Skip to content
This repository was archived by the owner on Aug 11, 2020. It is now read-only.
This repository was archived by the owner on Aug 11, 2020. It is now read-only.

Add Support for getLineHeightFactor() and setLineHeightFactor() functions #22

Open

Description

@Fadiabb

Hallo,
The following MrRio/jsPDF functions are not supported in yWork-jspdf Fork :
getLineHeightFactor() :
http://raw.githack.com/MrRio/jsPDF/master/docs/jsPDF.html#setLineHeightFactor
setLineDash() :
https://github.com/MrRio/jsPDF/blob/master/examples/js/lines.js#LC36

trying to use them :

<html>
<script src="../node_modules/jspdf-yworks/dist/jspdf.min.js"></script>
<body>
<script>
 const pdf = new jsPDF("l", "mm", "a3");
   pdf.setLineDash();
   pdf.getLineHeightFactor();
</script>
</body>
</html>

throws Errors:
Uncaught TypeError: pdf.getLineHeightFactor is not a function
Uncaught TypeError: pdf.setLineDash is not a function

Is the support of these function planned ?

Activity

  1. yGuy commented on Jun 11, 2019

    @yGuy
    Member

    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?

  2. added
    needs-infoThis issue is on hold, until more information becomes available.
    on Jun 11, 2019
  3. Fadiabb commented on Jun 11, 2019

    @Fadiabb
    Author

    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

  4. yGuy commented on Jun 11, 2019

    @yGuy
    Member

    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.

  5. added and removed
    needs-infoThis issue is on hold, until more information becomes available.
    on Jun 11, 2019
  6. bernhardreiter commented on Jul 2, 2019

    @bernhardreiter

    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.)

  7. HackbrettXXX commented on Jul 2, 2019

    @HackbrettXXX
    Member

    There is already a setLineDashPattern method. We can probably just delegate to it. Also, in "advanced" API mode we should not scale the values by k.

  8. bernhardreiter commented on Jul 3, 2019

    @bernhardreiter

    The upcoming jsPDF with parallax@849ce007 now already accepts setLineDashPattern() as part of getting more compatible, so implementing setLineDash is not necessary anymore.

  9. bernhardreiter commented on Jul 3, 2019

    @bernhardreiter

    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.

  10. changed the title [-]Add Support for some jspdf functions[/-] [+]Add Support for getLineHeightFactor() and setLineHeightFactor() functions[/+] on Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions