This little sample code shows how to add a font to a PDF document and than add some text content to the PDF using this newly embedded font, using Qoppa’s PDF library jPDFProcess.

// Create a blank document and add a page
PDFDocument pdf = new PDFDocument();
PDFPage newPage = pdf.appendNewPage(8.5 * 72, 11 * 72);
Graphics2D pageG2 = newPage.createGraphics();
 
// Embed the font
Font myFont = pdf.embedFont("myfont.ttf", Font.TRUETYPE_FONT);		
pageG2.setFont(myFont.deriveFont(12f));
pageG2.drawString("My message", 72, 108);
 
// Save the document
pdf.saveDocument("barcode.pdf");