Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for lineHeightFactor #1000

Merged
merged 1 commit into from
Oct 2, 2023
Merged

Add support for lineHeightFactor #1000

merged 1 commit into from
Oct 2, 2023

Conversation

mmghv
Copy link
Collaborator

@mmghv mmghv commented Oct 2, 2023

Fixes #767, #712, #753, #887, #802, #906

Reference PR : #754

Before

1

After

2

Example code

const doc = new jsPDF();

table(10, 'LineHeightFactor: 1.15 \n(default)')

doc.setLineHeightFactor(0.9)
table(80, 'LineHeightFactor: 0.9')

doc.setLineHeightFactor(2.5)
table(150, 'LineHeightFactor: 2.5')

function table(x, title) {
  doc.text(title, x, 40)

  doc.autoTable({
    body: [
      ['text\non\nfour\nlines'],
      ['text on one line'],
      ['text on one line'],
    ],
    theme: 'grid',
    tableWidth: 50,
    startY: 50,
    styles: {
      textColor: 'black',
      fontSize: 18,
      lineColor: 0,
      // cellPadding: 0,
    },
    margin: {left: x}
  })
}

@simonbengtsson
Copy link
Owner

Awesome! I guess this is technically a breaking change, but should we release it ahead of v4 anyway since it's such a nice addition? Or maybe simple release v4 as a minor update with bigger changes in V5?

@mmghv
Copy link
Collaborator Author

mmghv commented Oct 2, 2023

I don't think this is a breaking change, it was a bug, if you changed lineHeightFactor from the default, you get unexpected results (broken text in multiline cells) like shown in the image and reported in the issues.

So IMHO this should be merged in v3, I have no problem with it though if you want it to be deferred to v4.

@simonbengtsson
Copy link
Owner

Aha got it. I thought it was adding support for line height factor in jspdf but see what you mean now.

@simonbengtsson simonbengtsson merged commit 4c04f6a into master Oct 2, 2023
@mmghv
Copy link
Collaborator Author

mmghv commented Oct 2, 2023

I thought it was adding support for line height factor

It is adding support for lineHeightFactor from jspdf instead of using the hard-coded 1.15 value, so the line height could be changed with doc.setLineHeightFactor() jspdf method.

It was done before in this PR #754 but was not completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

increased lineHeight cuts off multi-line cells
2 participants