npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gm-pdfmake

v0.3.20

Published

Client/server side PDF printing in pure JavaScript

Readme

pdfmake

Client/server side PDF printing in pure JavaScript

Check out the playground and examples.

使用中文

pdfmake原文档有说明如何使用自定义字体Custom Fonts client side

通过看文档和gulpfile.js之后发现,主要3个点实现自定义字体:

  1. 把字体文件base64之后得到的字符串赋值给pdfMake.vfs
pdfMake.vfs = {
  "fontFile.ttf": "xxxxx",
  "fontFile2.ttf": "xxxxx",
  "fontFile3.ttf": "xxxxx",
  "fontFile4.ttf": "xxxxx"
}
  1. pdfMake.fonts中声明要用到的字体;
pdfMake.fonts = {
   yourFontName: {
     normal: 'fontFile.ttf',
     bold: 'fontFile2.ttf',
     italics: 'fontFile3.ttf',
     bolditalics: 'fontFile4.ttf'
   }
}
  1. 在PDF文档结构中指定使用的字体名称
var docDefinition = {
  content: (...),
  defaultStyle: {
    font: 'yourFontName'
  }
}

优化

由于字体文件太大,电脑上copy过来的字体大小在10~20M,不适合直接拿来用。这里我们在2个方向做了优化。

  1. 精减字体,提取7000常用汉字; 使用font-spider对字体做精简,具体可参考font-min-cut
  2. 分切base64之后的字符串,并行加载,然后在客户端拼接; 在gulpfile.json中,我添加了splitFontstask,gulp splitFonts之后会在build/splits目录下生成分切后的js文件。

Note

  1. 由于font-spider存在无法提取空格的bug,所以需要使用fontcreator进行字体编辑,添加空格,only windows版本。
  2. ./examples/fonts中的regular.ttfbold.ttf已经添加了空格,但是在观麦的配送单模块中,时常会出现某些客户的sku名称存在生僻字不在我们的7000常用字当中,这时需要我们提取这些生僻字,然后通过fontcreator软件把提取出来的生僻字添加到regular.ttfbold.ttf中,然后重新gulp splitFonts