pub struct TextField {
pub name: String,
pub default_value: Option<String>,
pub value: Option<String>,
pub max_length: Option<i32>,
pub multiline: bool,
pub password: bool,
pub file_select: bool,
pub do_not_spell_check: bool,
pub rich_text: bool,
pub default_appearance: Option<DefaultAppearance>,
}Expand description
Text field for entering text
Fields§
§name: StringField name (unique identifier)
default_value: Option<String>Default value
value: Option<String>Current value
max_length: Option<i32>Maximum length of text
multiline: boolWhether field is multiline
password: boolWhether field is password field
file_select: boolWhether field is file select
do_not_spell_check: boolWhether spellcheck is enabled
rich_text: boolWhether field allows rich text
default_appearance: Option<DefaultAppearance>Typed /DA (default appearance) — drives the font/size/colour used to
regenerate the field’s /AP/N when Document::fill_field is called.
When None, fill_field falls back to Helvetica + WinAnsi (which fails
for any non-WinAnsi value — see issue #212).
Implementations§
Source§impl TextField
impl TextField
Sourcepub fn with_default_appearance(
self,
font: Font,
font_size: f64,
color: Color,
) -> Self
pub fn with_default_appearance( self, font: Font, font_size: f64, color: Color, ) -> Self
Attach a typed default appearance (font, size, colour) that
Document::fill_field will use when regenerating the field’s /AP/N.
Required for non-WinAnsi fills (CJK, Arabic, Cyrillic outside basic
Latin, etc.) — the default built-in Helvetica cannot render those and
fill_field will otherwise return PdfError::EncodingError.
The font must be registered on the Document via
add_font_from_bytes if it’s a Font::Custom(_).
Sourcepub fn with_default_value(self, value: impl Into<String>) -> Self
pub fn with_default_value(self, value: impl Into<String>) -> Self
Set the default value
Sourcepub fn with_value(self, value: impl Into<String>) -> Self
pub fn with_value(self, value: impl Into<String>) -> Self
Set the current value
Sourcepub fn with_max_length(self, length: i32) -> Self
pub fn with_max_length(self, length: i32) -> Self
Set maximum length
Sourcepub fn to_dict(&self) -> Dictionary
pub fn to_dict(&self) -> Dictionary
Convert to field dictionary