parallax / jsPDF

Client-side JavaScript PDF generation for everyone.
https://parall.ax/products/jspdf
MIT License
29.32k stars 4.68k forks source link

Centering a multiline rotated text isn't working #3206

Open StriderRanger opened 3 years ago

StriderRanger commented 3 years ago

Hi,

In an Ionic/Angular app, I have a multiline text that is rotated with 45 degree, and when the text has the property align: 'left', the export is working fine. But once I change this property to align: 'center', the result is inappropriate, and the second line of the text moves to the very bottom-left corner of the page.

This is a stackblitz example, where the text has the property align: 'center', and rotated with 45 degree.

Please note that:

Thanks!

HackbrettXXX commented 3 years ago

Thanks for reporting this bug.

The issue seems to be here: https://github.com/MrRio/jsPDF/blob/cef97fb34eda41a8704c9f3983e680919a328ce4/src/jspdf.js#L3993-L4008

The da array (posX/Y) contains absolute coordinates for the first line and coordinates relative to the previous line for all other lines. This is an issue when passing the coordinates to the generatePosition function. For the non-rotated case, it uses the Td PDF operator, which also accepts relative positions. For the rotated case, it uses the Tm operator, which is not relative to the previous line. See also PDF 1.7 specification, section 9.4.2 Text-Positioning Operators.

Pull requests are welcome ;)

TechWizard9999 commented 1 year ago

😊 "I'd be delighted to work on this issue, @StriderRanger ! Could you please assign it to me?"

StriderRanger commented 1 year ago

Thanks for looking into this issue @TechWizard9999. I don't have the necessary permissions to assign the issue. It should be done by the repository owners.

2021eo3ar commented 3 weeks ago

@StriderRanger, Assign this issue to me please I can correct the bug.

StriderRanger commented 3 weeks ago

@HackbrettXXX Can you please assign this issue to @2021eo3ar

StriderRanger commented 2 weeks ago

There is candidates who can work on this issue, why it isn't assigned to them