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

Using multiple Standard Fonts for a single textfield (i.e. Merging Unicode code points) #1665

Open
ejduclervil opened this issue Aug 19, 2024 · 0 comments

Comments

@ejduclervil
Copy link

Describe your idea

This is kind of an idea/question. I spent some time trying to figure out how to accomplish this and couldn't figure it out. But I'm also pretty new to this library, so it might be possible and I'm simply unaware.

But the idea is pretty much in a title. pdf-lib supports 14 Standard Fonts and it'd be great if we could apply a combination of their character sets for a single textfield. This is more geared toward Symbol and ZapfDingbats.

How could this be implemented?

I'm not sure how easy/difficult it would be. In regards to implementation, we use the code below to change the default font.

const mergedFont = await pdfDoc.embedFont(font, options);

So maybe adding a couple more options with a boolean set to false.

const mergedFont = await pdfDoc.embedFont(StandardFonts.Helvetica, { applySymbol: true });

What problem are you trying to solve?

I think being specific about my situation would be the best way to explain what I mean.

Currently, I have a PDF form template that I’m filling using pdf-lib. The template will be stored on the app and we’ll simply be filling it with the user’s values. So I’m using getTextField and setText to accomplish this.

form.getTextField(“fieldName”).setText(this.inputVariable);

In one section of the PDF, the user has to mark the listed publication exists. On the PDF itself, there’s a list of each publication name with the date of publication in parenthesis and next to it is a single text field. If the date is good, they simply put a checkmark. If the date is different, they put a checkmark and write the new date:

Pub-1 (2018): ✓ 05/05/2020

The checkmark symbol exists in ZapfDingbats, but trying this throws an error since the unicode code points for numbers/letters don’t exist in ZapfDingbats. And similarly, the code point for the checkmark doesn’t exist in Helvetica.

Why does this matter to you?

It seems like the only way to accomplish this would be to use a custom font that contains all the letters/numbers/symbols I need, but it feels like a waste since everything I need exists in StandardFonts.

Would others find this helpful?

I think so.

Are you interested in implementing your proposal?

No

Why are you submitting a proposal?

While I'd love to take a crack at this, I'm so new at this, I wouldn't know where to begin. As I mentioned above, this might already be possible and I just wasn't able to figure it out. But if it doesn't. I thought this would be a useful feature others would be interested in.

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