Repository navigation
fix(textbox): rotated and typewriter text boxes from other editors keep their shape - #529
Merged
Merged
Conversation
…ep their shape - A text box turned by 90 degrees on a page with /Rotate 90 or 270 got its width and height swapped, because its size was worked out from the box in PDF coordinates while its angle is a screen angle. The size now comes from the box as it is displayed. - Typewriter text (/IT /FreeTextTypewriter, also spelled FreeTextTypeWriter) never wraps, but it was wrapped like an ordinary text box and grew over the next field. It now breaks only at hard line breaks. Saving writes /IT back and widens the box to the text as other viewers measure it, for any alignment. Text boxes saved by Open PDF Studio itself load and save as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What happened
The same drawing (annotations made in another editor, page
/Rotate 90) showed two text box problems:/Rotate 270on the annotation, the rotation in the appearance/Matrix) were drawn wide and short with clipped text instead of tall and narrow.tekstvakMaatworked out width and height from the/Rectin PDF coordinates while the angle is a display angle; on a/Rotate 90or270page those axes are swapped. Files saved by Open PDF Studio hid this, because their appearance has a singlerethat is read directly; this producer writes two./IT /FreeTextTypewriter, which never wraps. The app wrapped them like ordinary text boxes. The producer makes the box exactly as wide as the text, so a measurement 0.005 pt wider broke a two-word name onto two lines over the next field (on a PC without the font, more fields broke or overflowed). Saving then wrote the wrap into the file and dropped/IT.What this changes
js/pdf/loader/tekstvak-rotatie.js: the size comes from the box as displayed (rectVp), without rounding; an orientation check for the appearance rectangle, with guards (callouts, near 45 degrees, negative or far-off results)./IT /FreeTextTypewriter, also the spellingFreeTextTypeWriter):noWrapin the model; the layout breaks only at hard line breaks; the editor useswhite-space: pre; the canvas does not clip it./IT /FreeTextTypewriterback and widens/Rectand/BBoxto the widest line as other viewers measure it (the larger of the canvas width and the substitute standard font), for left, centred and right alignment; non-standard font names map to a standard font instead of failing.js/pdf/saver-test-hooks.mjslets node tests run the realsaver.js.Unchanged
Text boxes saved by Open PDF Studio itself (including callouts and the
/DSmargin from 2026.39.2): six own variants on four page rotations save identically except/M, and load to identical models. Ordinary FreeText and callouts from other programs still wrap.Verification
npm run test:unit2629 passed, 0 failed;npx vite buildandnpm run typecheckgreen; the changed tests also pass with--no-experimental-strip-types.Helvetica-*font names, centred and right alignment past the box); all fixed test-first.🤖 Generated with Claude Code