PDTrueTypeFont font = PDTrueTypeFont.loadTTF(_pdfDocument, fontStream) InputStream fontStream = getClass().getResourceAsStream("LiberationSans-Regular.ttf") PDResources res = acroForm.getDefaultResources() If you want to use an own font, you first need to register it in the AcroForm default resources like this: public String prepareFont(PDDocument _pdfDocument) throws IOException Any out of the box fonts that do that? If not, if I have my own font, how do I set in the method to be written to the PDF? I would like to use one or more fonts that look like Signatures (cursive). If I understand right, there are 14 basic fonts that I can use in PDFBox out of the box (pun unintended).fill and stroke, and use a line width of. 5 w 0 g") ĭict.setString(COSName.DA, "/Helv 12 Tf 0 g")
PDAcroForm acroForm = docCatalog.getAcroForm() ĬOSDictionary dict = ((PDField) field).getDictionary() ĬOSString defaultAppearance = (COSString) dictĭict.setString(COSName.DA, "/Helv 10 Tf 2 Tr. PDDocumentCatalog docCatalog = _pdfDocument.getDocumentCatalog() not only filling the letter but also stroking a line along its borders: public static void setFieldBold(String name, String value) throws IOException If you don't have such a bold font at hands, you may instead use some poor-man's-bold technique, e.g.
#JAVA FONT NAMES PDF#
In PDF you usually make text bold by using a font with bold glyphs, also see your second question.
(You can find a runnable example here: FillFormCustomFont.java) Using poor-man's-bold