I want to use Verdana as a font while stamping a PDF file with iText PDF. The original file uses Verdana, which isn\'t an option in the class Basefont.
Here is the f
As documented, iText supports the Standard Type 1 fonts, because iText ships with AFM file (Adobe Font Metrics files). iText has no idea about the font metrics of other fonts (Verdana isn't a Standard Type 1 font). You need to provide the path to the Verdana font file.
BaseFont.createFont("c:/windows/fonts/verdana.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED)
Note that I change false
to BaseFont.EMBEDDED
because the same problem you have on your side, will also occur on the side of the person who looks at your file: his PDF viewer can render Standard Type 1 fonts, but may not be able to render other fonts such as Verdana.
Caveat: The hard coded path "c:/windows/fonts/verdana.ttf"
works for me on my local machine because the font file can be found using that path on my local machine. This code won't work on the server where I host the iText site, though (which is a Linux server that doesn't even have a c:/windows/fonts
directory). I am using this hard coded path by way of example. You should make sure that the font is present and available when you deploy your application.