Skip to content

Add widthOfText function to PDFPage #109

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ATLCTO
Copy link

@ATLCTO ATLCTO commented May 29, 2025

What?

Helper function to calculate the width of some text so I can tweak the font size slightly to get the text to fit.

Why?

I am re-creating a document and I don't have access to the exact some fonts so I need to tweak the font size slightly to get the same layout.

How?

It's essentially the drawText function (just without the drawing).

Testing?

It's just a few lines of code from drawText and we've been using in production for a year or two, just trying to cleanup my build scripts and contribute the code to a upstream fork that will be maintained.

New Dependencies?

None

Screenshots

N/A

Suggested Reading?

No

Anything Else?

None

Checklist

  • [ ‭✓] I read CONTRIBUTING.md.
  • [ ‭✓] I read MAINTAINERSHIP.md#pull-requests.
  • I added/updated unit tests for my changes.
  • I added/updated integration tests for my changes.
  • I ran the integration tests.
  • I tested my changes in Node, Deno, and the browser.
  • I viewed documents produced with my changes in Adobe Acrobat, Foxit Reader, Firefox, and Chrome.
  • [ ‭✓] I added/updated doc comments for any new/modified public APIs.
  • [ ‭✓] My changes work for both new and existing PDF files.
  • [ ‭✓] I ran the linter on my changes.

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

Successfully merging this pull request may close these issues.

1 participant