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

How to use PDFKit standard PDF fonts #1517

Closed
Focushift opened this issue Oct 9, 2018 · 5 comments
Closed

How to use PDFKit standard PDF fonts #1517

Focushift opened this issue Oct 9, 2018 · 5 comments

Comments

@Focushift
Copy link

It is possible to use PDFKit standard fonts?

If we look at PDFKit example http://pdfkit.org/demo/browser.html
It is not required to load additional font to draw text with Times-Roman.
But looks like that pdfmake bundling not includes PDFKit files required for standard fonts support.

@blikblum
Copy link
Contributor

#1523 allows to use afm fonts which is used by pdfkit to support the 14 PDF Standard fonts

It requires to store the afm font data without converting to buffer so the needed change

I abstracted the loading and configuration in PdfAssetsLoader class from https://github.com/blikblum/pdfmake-utils

A full example of how to setup Standard fonts can be found at: https://github.com/blikblum/pdfmake-playground/blob/master/src/setup/components.js#L9-L12

@liborm85
Copy link
Collaborator

liborm85 commented Oct 21, 2018

Standard 14 fonts are supported by pdfmake on server-side by default.
But on client-side is not supported by default because it increase file size about 700 kB. And fonts are only with ANSI code page (only english characters). I'm implemented command for building with standard fonts for client-side by commit 903f767.

How to use standard 14 fonts in pdfmake are described in wiki page.

(reference #101)

@Focushift
Copy link
Author

Ok, thanks.

Another question - if i need support for another languages, i just convert ttf font to afm and replace afm from pdfkit?

@blikblum
Copy link
Contributor

No, use ttf directly

@schmidtc63
Copy link

I tried using the example code but I'm getting errors:

var PdfPrinter = require('pdfmake'); // generates error SCRIPT5022: Cannot find module 'pdfmake'
var printer = new PdfPrinter(fonts);
var fs = require('fs'); //generates error SCRIPT5022: Cannot find module 'fs'

Thank you for any assistance.

Chris

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

4 participants