class CreateSimpleFormWithEmbeddedFont
{
    private CreateSimpleFormWithEmbeddedFont()
    {
    }

    public static void main(String[] args) throws IOException
    {<FILL_FUNCTION_BODY>}
}

        // Create a new document with an empty page.
        try (PDDocument doc = new PDDocument())
        {
            PDPage page = new PDPage(PDRectangle.A4);
            doc.addPage(page);
            PDAcroForm acroForm = new PDAcroForm(doc);
            doc.getDocumentCatalog().setAcroForm(acroForm);

            // Note that the font is fully embedded. If you use a different font, make sure that 
            // its license allows full embedding.
            PDFont formFont = PDType0Font.load(doc, CreateSimpleFormWithEmbeddedFont.class.getResourceAsStream(
                    "/org/apache/pdfbox/resources/ttf/LiberationSans-Regular.ttf"), false);

            // Add and set the resources and default appearance at the form level
            final PDResources resources = new PDResources();
            acroForm.setDefaultResources(resources);
            final String fontName = resources.add(formFont).getName();
            
            // Acrobat sets the font size on the form level to be
            // auto sized as default. This is done by setting the font size to '0'
            acroForm.setDefaultResources(resources);
            String defaultAppearanceString = "/" + fontName + " 0 Tf 0 g";

            PDTextField textBox = new PDTextField(acroForm);
            textBox.setPartialName("SampleField");
            textBox.setDefaultAppearance(defaultAppearanceString);
            acroForm.getFields().add(textBox);

            // Specify the widget annotation associated with the field
            PDAnnotationWidget widget = textBox.getWidgets().get(0);
            PDRectangle rect = new PDRectangle(50, 700, 200, 50);
            widget.setRectangle(rect);
            widget.setPage(page);
            page.getAnnotations().add(widget);

            // set green border and yellow background
            // if you prefer defaults, delete this code block
            PDAppearanceCharacteristicsDictionary fieldAppearance
                    = new PDAppearanceCharacteristicsDictionary(new COSDictionary());
            fieldAppearance.setBorderColour(new PDColor(new float[]{0,1,0}, PDDeviceRGB.INSTANCE));
            fieldAppearance.setBackground(new PDColor(new float[]{1,1,0}, PDDeviceRGB.INSTANCE));
            widget.setAppearanceCharacteristics(fieldAppearance);

            // set the field value. Note that the last character is a turkish capital I with a dot,
            // which is not part of WinAnsiEncoding
            textBox.setValue("Sample field İ");

            // put some text near the field
            try (PDPageContentStream cs = new PDPageContentStream(doc, page))
            {
                cs.beginText();
                cs.setFont(new PDType1Font(FontName.HELVETICA), 15);
                cs.newLineAtOffset(50, 760);
                cs.showText("Field:");
                cs.endText();
            }

            doc.save("target/SimpleFormWithEmbeddedFont.pdf");
        }
    
<no_super_class>