public class FormManager extends Object
PdfDocument.
| Constructor and Description |
|---|
FormManager(com.ironsoftware.ironpdf.internal.staticapi.InternalPdfDocument internalPdfDocument)
Please get FormManager by
PdfDocument.getForm() instead. |
| Modifier and Type | Method and Description |
|---|---|
void |
disableFormFontFallback()
Suppresses the automatic Tahoma/Arial fallback embed for non-ASCII form values without
registering any replacement font.
|
void |
flatten()
Flattens a document (make all form fields non-editable).
|
void |
flatten(PageSelection pageSelection)
Flattens a document (make all form fields non-editable).
|
FormFieldsSet |
getFields()
Get a collection of the user-editable form fields within a PDF document
|
String |
renameField(String currentFieldName,
String newFieldName)
Rename a
FormField |
void |
setFieldReadOnly(String fieldName,
boolean value)
Set the is read only value of a
FormField |
void |
setFieldValue(String fieldName,
String value)
Set the string value of a
FormField |
void |
setFormFont(String fontName)
Sets the document-wide form font by name only.
|
void |
setFormFont(String fontName,
byte[] fontData)
Sets the document-wide form font without forcing a re-embed.
|
void |
setFormFont(String fontName,
byte[] fontData,
boolean forceEmbed)
Sets the document-wide font for all subsequent form-field fills on this document.
|
void |
setFormFontFromFile(Path fontFilePath)
Loads a TrueType/OpenType font from disk and applies it as the document-wide form font.
|
void |
setFormFontFromFile(Path fontFilePath,
String fontName,
boolean forceEmbed)
Loads a TrueType/OpenType font from disk and applies it as the document-wide form font.
|
void |
setTextFieldFont(String textFieldName,
FontTypes font,
int fontSize)
Deprecated.
This method is deprecated and no longer has any effect.
Set the font of a
TextField |
public FormManager(com.ironsoftware.ironpdf.internal.staticapi.InternalPdfDocument internalPdfDocument)
PdfDocument.getForm() instead.internalPdfDocument - the internal pdf documentpublic final void flatten()
public final void flatten(PageSelection pageSelection)
pageSelection - Selected page indexes. Default is all pages.public FormFieldsSet getFields()
public String renameField(String currentFieldName, String newFieldName)
FormFieldcurrentFieldName - Current fully qualified field namenewFieldName - New partial field name Please use a fully qualified field name for
CurrentFieldName, and a partial field name for NewFieldNamepublic void setFieldValue(String fieldName, String value)
FormFieldfieldName - Fully qualified field namevalue - New valuepublic void setFieldReadOnly(String fieldName, boolean value)
FormFieldfieldName - Fully qualified field namevalue - is read onlypublic void setTextFieldFont(String textFieldName, FontTypes font, int fontSize)
TextFieldtextFieldName - Fully qualified field namefont - New fontfontSize - New font sizepublic void setFormFont(String fontName, byte[] fontData, boolean forceEmbed)
The engine only auto-embeds the Tahoma/Arial fallback when a form value containing non-ASCII characters is set. Every other field update (renaming, toggling read-only, etc.) leaves fonts untouched, so this method is only useful when at least one of your fills contains non-ASCII characters.
If your form fields reference more than one font variant (e.g. Poppins-Regular and Poppins-Bold), call this method once per variant.
File-size impact
fontData is null/empty): zero bytes added; the font must already be in the document.forceEmbed = true: a fresh font copy is added alongside any existing copy; the document grows by the size of the new font on every call. Use sparingly.fontName - PDF font name to register (e.g. "Poppins-Regular"). Allowed characters: letters, digits, '-', '_', '.', '+'.fontData - Raw TrueType/OpenType bytes; pass null or empty for name-only mode (the font must already be in the document).forceEmbed - When true, embed fontData even if a font with the same name and usable glyph data is already present. Has no effect in name-only mode.IllegalArgumentException - when fontName or fontData fails validationpublic void setFormFont(String fontName, byte[] fontData)
setFormFont(fontName, fontData, false).fontName - PDF font name to registerfontData - Raw font bytes, or null/empty for name-only modeIllegalArgumentException - when fontName or fontData fails validationpublic void setFormFont(String fontName)
fontName - PDF font name as it appears in the documentIllegalArgumentException - when fontName fails validationpublic void setFormFontFromFile(Path fontFilePath) throws IOException
fontFilePath - Path to a TTF/OTF/TTC font fileIOException - when the font file cannot be readIllegalArgumentException - when the file or derived font name fails validationpublic void setFormFontFromFile(Path fontFilePath, String fontName, boolean forceEmbed) throws IOException
fontFilePath - Path to a TTF/OTF/TTC font filefontName - Optional PDF font name to register the font under. When null, the file name without extension is used.forceEmbed - When true, embed even if the font is already present.IOException - when the font file cannot be readIllegalArgumentException - when the file or derived font name fails validationpublic void disableFormFontFallback()
Rendering of non-ASCII characters then depends entirely on the viewer's font substitution
— best for ASCII or Latin-Extended fills where the template already references suitable
fonts. For broader character ranges, use setFormFont(String, byte[], boolean)
instead.
Copyright © 2022–2026 Iron Software. All rights reserved.