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

drawText does not render multiple sequential line breaks. #1580

Open
2 tasks done
ryangriggs opened this issue Jan 2, 2024 · 0 comments
Open
2 tasks done

drawText does not render multiple sequential line breaks. #1580

ryangriggs opened this issue Jan 2, 2024 · 0 comments

Comments

@ryangriggs
Copy link

What were you trying to do?

Rendering text such as:

let text = `Hello world
this is the second line

and there is space before this line`;

page.drawText(text, { font: timesRoman,
					size: 12,
					lineHeight: timesRoman.heightAtSize(12) +  3,
					x: 88.56, // 1.23" from left
					y: 648,	// 1" from top
					maxWidth: 434.88,	// 1.23" margin on each side
});

Would render:

Hello world
this is the second line
and there is space before this line

(the extra \n or \r\n lines are ignored)

A workaround is to type an invisible character (a Space) on each blank line. This would force the new lines to be rendered.

How did you attempt to do it?

See above.

What actually happened?

The multiple \r\n lines were ignored.

What did you expect to happen?

Each blank line containing only \r\n should move the pointer down a full line.

How can we reproduce the issue?

see the above example.

Version

latest

What environment are you running pdf-lib in?

Node

Checklist

  • My report includes a Short, Self Contained, Correct (Compilable) Example.
  • I have attached all PDFs, images, and other files needed to run my SSCCE.

Additional Notes

No response

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

No branches or pull requests

1 participant