In iText 7 you can create a
PdfFont from a
byte, using the
createFont() method. Suppose that
fBytes is a
byte, then you'd have:
PdfFont font = PdfFontFactory.createFont(fBytes, PdfEncodings.IDENTITY_H, true);
You can chose different encodings depending on the type of your font. The last parameter is a
boolean embedded value.
Now you can use
font as usual:
doc.add(new Paragraph(“Hello World!”).setFont(font).setFontSize(12));
Whether you are working with Type 1 font, you should use
PdfFont type1font = PdfFontFactory.createFont(FontProgramFactory.createType1Font(afm, pfb), null);
As you know, Type 1 fonts consist of two files: a metrics file (AFM or PFM) and a font binary (PFB). In the code above
pfb are byte arrays.
Click this link if you want to see how to answer this question in iText 5.