Is it possible to set the character set to UTF-8 or a locale (type "es-ES" for example) "?
I just started doing tests with pdf-lib, and I'm wondering if you can set the character set to my locale (in this case 'es-ES') to be able to see all the characters correctly. My program fills in a pdf form, and it gets it without problems. Although with the exception of course of the Spanish characters. Here is my code. informevnpdflib.zip
Hello @patryn32. I'm afraid there is not currently a way to change the character set or locale. This is something that I'd definitely like to support, though. I've placed it on the TODO.md file.
I can't make any promises as to when I'll get around to implementing this. However, if non-english text is an absolute requirement for you, one (hacky) way to get it done would be to produce an image of the text (perhaps using node-canvas) and draw that image onto the PDF. You can find an example of drawing an image on a PDF in this example.
Hi,
I can suggest to add Encoding 'WinAnsiEncoding' to the Font dictionary.
See https://github.com/jerp/pdf-lib/commit/199ecf2d67fa734f31f4caa332abe1a36460d8d1
Check out result in attached document (see "distribución") - I din't have the original doc, so I used the one in test-pdf directory
Version 0.4.0 is now published. It contains support for the WinAnsi character set when using one of the Standard 14 Fonts (example). The full release notes are available here.
You can install this new version with npm:
npm install [email protected]
It's also available on unpkg:
- https://unpkg.com/[email protected]/dist/pdf-lib.js
- https://unpkg.com/[email protected]/dist/pdf-lib.min.js
@jerp Thanks for your contributions to this release!
Version 0.6.0 is now published. It contains support for the full range of UTF-8 and UTF-16 characters included in embedded fonts (example). The full release notes are available here.
You can install this new version with npm:
npm install [email protected]
It's also available on unpkg:
- https://unpkg.com/[email protected]/dist/pdf-lib.js
- https://unpkg.com/[email protected]/dist/pdf-lib.min.js
Hi,
This may be a stupid question but, does It contains support for the full range of UTF-8 and UTF-16 characters included in embedded fonts mean I can use a custom font and print characters in said font just fine ? (I'm trying to print chinese characters)
@shxdow That is correct. So long as the font you embed supports a particular character, you should be able to draw it on a PDF page with pdf-lib.