This is a very simple sample console app written in C# that illustrates how you can use a subsets of fonts to generate smaller sized PDF's using QuestPDF
This is based on an issue 31 in the QuestPDF GitHub repo.
This repo contains 2 font subsets, created with the steps mentioned below. The resulting PDF is 30 pages and it's size, using different fonts are:
Font | Approx. File Size (bytes) |
---|---|
Noto Sans | 267 |
NotoSansSmall | 93 |
NotoSansSmall2 | 65 |
Calibri | 824 |
CalibriSmall | 83 |
Tahoma | 564 |
Segoe UI | 595 |
Arial | 590 |
- Go to https://everythingfonts.com/subsetter (There is a cost involved if you want to convert large fonts)
- Upload the file & select the following options: a) Basic Latin b) Uppercase c) Lowercase d) Numerals e) Basic Punctuation f) Currency Symbols
- Generate and download the created file
- Use FontForge. File > Open & open the created subset font file
- Select Element Menu > Font Info
- Create a new name for the font in the following fields e.g CalibriSmall a) Fontname b) Family Name c) Name for Humans
- Click Ok. When prompted, overwrite the GUID for the font.
- File Menu > Generate Fonts a) Set Type to TrueType b) Click Generate
Install the newly created font on your system and in you code use the font name CalibriSmall