Skip to content

Fix cell.js getTextDimensions doesn't respect lineHeightFactor option - #3814

Closed
imjosh wants to merge 1 commit into
parallax:masterfrom
imjosh:update-celljs-getTextDimensions
Closed

imjosh wants to merge 1 commit into
parallax:masterfrom
imjosh:update-celljs-getTextDimensions

Conversation

@imjosh

@imjosh imjosh commented Jan 22, 2025

Copy link
Copy Markdown

Before/After
image

var doc = new jsPDF();
const textOptions = {
  maxWidth: 50,
  lineHeightFactor: 1.5
};

const paragraphs = [
  '1. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean tempor leo tellus, ut luctus mi aliquet a. Aenean id mauris volutpat, ullamcorper libero a, bibendum leo. Praesent ut enim sapien. Ut et felis interdum, molestie eros quis, facilisis odio.',
  '2. Cras risus ex, dapibus eu interdum in, placerat eu neque. Quisque venenatis tellus ac aliquam eleifend.',
  '3. Nunc ex urna, laoreet a gravida molestie, bibendum ac tellus. Nulla finibus sed lectus porta elementum. Suspendisse potenti. Sed quis purus at nunc sollicitudin posuere.',
];

let y = 15;
paragraphs.forEach(paragraph => {
  const height = doc.getTextDimensions(paragraph, textOptions).h;
  doc.text(paragraph, 15, y, textOptions);
  y += height + 5;
});

@imjosh
imjosh marked this pull request as ready for review January 22, 2025 23:35
@imjosh

imjosh commented Jan 22, 2025

Copy link
Copy Markdown
Author

Related to #1933

@github-actions github-actions Bot added the Stale label Apr 23, 2025
@github-actions github-actions Bot closed this Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant