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

Custom font Not Work, With An Error:No unicode cmap for font #923

Closed
GuanQiuQiao opened this issue Mar 24, 2017 · 6 comments
Closed

Custom font Not Work, With An Error:No unicode cmap for font #923

GuanQiuQiao opened this issue Mar 24, 2017 · 6 comments

Comments

@GuanQiuQiao
Copy link

I just started to use pdfmake,When I follow the step as this article advice (#33 new vfs_fonts.js is created,but it can't work,the error As is shown in the screenshots:
Uploading B2LHML_DR8FYJ}C_YEL)L}I.jpg…

I really need help,Thanks in advance.

@liborm85
Copy link
Collaborator

Screenshot not uploaded, you can upload it again?

@GuanQiuQiao
Copy link
Author

It since that I can't upload the screenshot,So I type it as the follow:

Uncaught Error:No unicode cmap for font
at t.registerTTF(http://localhost:8025/js/pdfmake.min.js:14:6016)
at new t (http://localhost:8025/js/pdfmake.min.js:14:3106)
at r.font (http://localhost:8025/js/pdfmake.min.js:14:1957)
at r.getFont (http://localhost:8025/js/pdfmake.min.js:9:7442)
at r.widthOfString (http://localhost:8025/js/pdfmake.min.js:9:7604)
at http://localhost:8025/js/pdfmake.min.js:9:25981
at Array.forEach(native)
at h (http://localhost:8025/js/pdfmake.min.js:9:25668)
at n.buildInlines (http://localhost:8025/js/pdfmake.min.js:9:26514)
at r.measureLeaf (http://localhost:8025/js/pdfmake.min.js:9:19814)

Looking forward to your reply,Thank you

@liborm85
Copy link
Collaborator

This error throw version 0.1.20 (or older). Update to the latest version - https://github.com/bpampuch/pdfmake/releases/latest.

@GuanQiuQiao
Copy link
Author

GuanQiuQiao commented Mar 27, 2017

Update to the latest version,The problem has been solved,Thank you very much.But another error appeard:

   Uncaught File '../../fonts/msyh.ttf' not found in virtual file system
   Document._openPdf @ pdfmake.js:172
   Document.open @ pdfmake.js:180
   test @ (index):797
   (anonymous) @ VM157:1

My project structure(MVC) is as follows:

PdfMakeTest(My project Name)
------fonts
---------msyh.ttf
------js
---------pdfmake.js
---------vfs_fonts.js
------View
--------Test
-----------pdfmake.cshtml(this view require pdfmake.js and vfs_fonts.js ,var dd = {...})

My code:

var dd={
    defaultStyle: {
              font: 'msyh'
          },
     content: (...)
 }   

 pdfMake.fonts = {
             msyh: {
              normal: '../../fonts/msyh.ttf',
              bold: '../../fonts/msyh.ttf',
              italics: '../../fonts/msyh.ttf',
              bolditalics: '../../fonts/msyh.ttf',
          }
   }    

I confused that why it can't find the msyh.ttf

@liborm85
Copy link
Collaborator

Here it is described how to add custom fonts: https://github.com/bpampuch/pdfmake/wiki/Custom-Fonts---client-side

Fonts must be in vfs_fonts.js file. A definition font file names must be without path.

@GuanQiuQiao
Copy link
Author

Thank you very much,The pdf has been successfully opened.Thank you for providing so powerful and convenient tool

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

No branches or pull requests

2 participants