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
Calling layoutMultilineText to handle wrapping text in my PDFs.
How did you attempt to do it?
First of all, thanks for the fantastic library! 🥇
I'm using layoutMultilineText to handle wrapping text in my PDFs. When passing a long string (thousands of characters), the function takes a very long time to execute. The execution time increases with font size.
I've observed this in multiple Node JS 14.7 environments.
What actually happened?
A string of length 10 thousand is takes over 30 seconds at font size size 12.
What did you expect to happen?
It's reasonable for there to be some upper limit, but I ran into this with a production work load with an actual string entered by a user. I would expect a 10 thousand character string to take no more than a few seconds.
How can we reproduce the issue?
let text = '';
for (let i = 0; i < 2000; i++) {
text += 'test ';
}
const now = Date.now();
layoutMultilineText(text, {
alignment: TextAlignment.Left,
bounds: {
width: 500,
height: 500,
x: 0,
y: 0
},
font,
fontSize: 12,
});
console.log(Date.now() - now); // 30 to 40 seconds
Version
1.17.1
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
Again, thanks for your efforts in maintaining this terrific library!
I believe I have a fix for this and will follow up with a PR.
The text was updated successfully, but these errors were encountered:
What were you trying to do?
Calling
layoutMultilineText
to handle wrapping text in my PDFs.How did you attempt to do it?
First of all, thanks for the fantastic library! 🥇
I'm using
layoutMultilineText
to handle wrapping text in my PDFs. When passing a long string (thousands of characters), the function takes a very long time to execute. The execution time increases with font size.I've observed this in multiple Node JS 14.7 environments.
What actually happened?
A string of length 10 thousand is takes over 30 seconds at font size size 12.
What did you expect to happen?
It's reasonable for there to be some upper limit, but I ran into this with a production work load with an actual string entered by a user. I would expect a 10 thousand character string to take no more than a few seconds.
How can we reproduce the issue?
Version
1.17.1
What environment are you running pdf-lib in?
Node
Checklist
Additional Notes
Again, thanks for your efforts in maintaining this terrific library!
I believe I have a fix for this and will follow up with a PR.
The text was updated successfully, but these errors were encountered: