What is the default font being used if doesn't have support for the font?

Product:
PdfNet sdk for kotlin / java .

Product Version:
10.1.0

Please give a brief summary of your issue:
(Think of this as an email subject)
I am trying to fill a form that needs a certain font Minion Pro but it is defaulting to Arial. I couldn’t find in the documentation regarding the default fall back font being Arial.

Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)

Please provide a link to a minimal sample where the issue is reproducible:

1 Like

You can use the SDF object model for the field object to change the font name for field instances. Here is an example to change a field font name in Java:

import com.pdftron.pdf.Field;
import com.pdftron.pdf.PDFDoc;
import com.pdftron.pdf.PDFNet;
import com.pdftron.sdf.SDFDoc.SaveMode;

class _58974_SDK_JAVA {
    public static void main(String[] args) {    
        String strPath = System.getProperty("user.dir") + "/";
        String fieldName = "Text1";
        String fontName = "TimesNewRoman";
        String inputFile = "field.pdf";
        String outputFile = "58974.Output.pdf";

        PDFNet.initialize("[YOUR LICENSE HERE]");
        try {

            PDFDoc in_doc = new PDFDoc(String.format("%s%s", strPath, inputFile));
            Field fld = in_doc.getField(fieldName);
            if (fld != null) {
                System.out.println(String.format("Field search for %s was successful. Updating font to %s.", fieldName, fontName));
                String da_str = String.format("/%s 0 Tf 0 g", fontName);
                fld.getSDFObj().putString("DA", da_str);
                in_doc.refreshFieldAppearances();
            } else {
                System.out.println("Field search failed.");
            }
            in_doc.save(String.format("%s%s", strPath, outputFile), SaveMode.LINEARIZED, null);
            in_doc.close();

        }catch (Exception e) {
            System.err.println(e.getMessage());
            e.printStackTrace(System.err);
        }
    }
}
1 Like