Recently, I delved into the PDFMake documentation in hopes of creating a document for my Angular application. Along the way, I stumbled upon queries like this one, but unfortunately, found no answers.
I am curious if anyone can offer insight or provide a clear example on how to import custom fonts for PDFMake within an Angular project. I have downloaded the files for the "Lato" font, but I am unsure of the next steps.
As per the documentation, I did successfully import the library:
import pdfMake from 'pdfmake/build/pdfmake';
import pdfFonts from 'pdfmake/build/vfs_fonts';
pdfMake.vfs = pdfFonts.pdfMake.vfs;
Additionally, I came across an example that included the following declaration:
pdfMake.fonts = {
Lato: {
normal: 'assets/fonts/Lato-Regular.ttf'
}
};
This snippet provided information on naming the font, specifying its weight, and indicating the file's location, but I remain uncertain on how to instruct PDFMake to utilize this font.
Any guidance on this matter would be greatly appreciated, as I have been mulling over this for quite some time.
UPDATE: After adhering to the guidelines outlined in the documentation, I managed to implement the Lato font by directly adjusting the files within the pdfmake node_modules directory. While this approach worked, I wish to refrain from modifying node_modules as it may lead to difficulties tracking changes or accessing them on different machines while running the project.