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

Error when generating pdf with chinese characters #472

Open
AdrianKochanski opened this issue Apr 18, 2024 · 1 comment
Open

Error when generating pdf with chinese characters #472

AdrianKochanski opened this issue Apr 18, 2024 · 1 comment
Labels

Comments

@AdrianKochanski
Copy link

Describe the bug

The template designer is displaying the chinese characters in the right way, but the generation pdf with the same data is not working.

To Reproduce

pdfme_template.json

Use the template above for generating the pdf with the data below:
[["1","47545843","","收割机转子(滚筒)","01654","","HR015","","Yes","05/08/2022","Yes"],["1","47613135","","泵 辅助","0522013616","","HR043","","Yes","12/08/2022","No"],["1","47984257","","CAB W/HEATER AND AC","2201","","HR014","","Yes","15/08/2022","Yes"],["1","51443795","","轮胎总成, 28L-26 18PR R2","2DHB010301","","HR040","","Yes","15/08/2022","No"]]

Expected behavior

Exports works with UTF-8 characters

Your Environment

- pdfme package: @pdfme/generator
- pdfme version: 4.0.0
- Operating system: Windows 11
- Browser name & version: Microsoft Edge for Business Version 123.0.2420.97 (Official build) (64-bit)

Your Error Log

An error occurred.Uncaught (in promise): Error: WinAnsi cannot encode "" (0x6536) Error: WinAnsi cannot encode "" (0x6536) at Encoding.encodeUnicodeCodePoint

Additional context

An error occurred.Uncaught (in promise): Error: WinAnsi cannot encode "收" (0x6536)
Error: WinAnsi cannot encode "收" (0x6536)
at Encoding.encodeUnicodeCodePoint (http://localhost:4200/node_modules_pdfme_schemas_dist_esm_src_index_js-_abcb0.js:32:15)
at StandardFontEmbedder.encodeTextAsGlyphs (http://localhost:4200/node_modules_pdfme_schemas_dist_esm_src_index_js-_abcb0.js:38067:35)
at StandardFontEmbedder.encodeText (http://localhost:4200/node_modules_pdfme_schemas_dist_esm_src_index_js-_abcb0.js:38000:25)
at PDFFont.encodeText (http://localhost:4200/node_modules_pdfme_schemas_dist_esm_src_index_js-_abcb0.js:24527:26)
at PDFPage.drawText (http://localhost:4200/node_modules_pdfme_schemas_dist_esm_src_index_js-_abcb0.js:25721:35)
at http://localhost:4200/node_modules_pdfme_schemas_dist_esm_src_index_js-_abcb0.js:6315:12
at Array.forEach ()
at http://localhost:4200/node_modules_pdfme_schemas_dist_esm_src_index_js-_abcb0.js:6295:11
at Generator.next ()
at asyncGeneratorStep (http://localhost:4200/vendor.js:7485:24)

ERROR Error: Uncaught (in promise): Error: WinAnsi cannot encode "收" (0x6536)
Error: WinAnsi cannot encode "收" (0x6536)
at Encoding.encodeUnicodeCodePoint (Encoding.js:18:23)
at StandardFontEmbedder.encodeTextAsGlyphs (StandardFontEmbedder.js:84:41)
at StandardFontEmbedder.encodeText (StandardFontEmbedder.js:25:29)
at PDFFont.encodeText (PDFFont.js:34:30)
at PDFPage.drawText (PDFPage.js:851:41)
at pdfRender.js:101:14
at Array.forEach ()
at pdfRender.js:83:11
at Generator.next ()
at asyncGeneratorStep (asyncToGenerator.js:3:1)
at resolvePromise (zone.js:1211:31)
at zone.js:1118:17
at zone.js:1134:33
at asyncGeneratorStep (asyncToGenerator.js:6:1)
at _throw (asyncToGenerator.js:25:1)
at _ZoneDelegate.invoke (zone.js:372:26)
at Object.onInvoke (core.mjs:25620:33)
at _ZoneDelegate.invoke (zone.js:371:52)
at Zone.run (zone.js:134:43)
at zone.js:1275:36

@hand-dot
Copy link
Collaborator

I checked the template.json you attached.
In that file, we can see NotoSerifJP-Regular in a fontName prop. NotoSerifJP-Regular doesn't contain Chinese characters.

So please set a Chinese Custom Fonts in a generator and UI packages.

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

No branches or pull requests

2 participants