PDF.js doesn't have a convenient API to extract the fonts from the pdf. This is a wrapper on top of PDF.js to help with same.
npm install pdf-font-extract
import extractFonts from 'pdf-font-extract';
const fonts = await extractFonts('./example.pdf');
console.log(fonts);
- Types are provided with JSDoc.
- It's only possible to extract the glyphs that were present in the pdf. Glyphs for characters not found in the pdf will be missing from the font.