PDFsharp-net6

PdfAcroField

Namespace: PdfSharp.Pdf.AcroForms

Represents the base class for all interactive field dictionaries.

public abstract class PdfAcroField : PdfSharp.Pdf.PdfDictionary, System.ICloneable, System.Collections.Generic.IEnumerable`1[[System.Collections.Generic.KeyValuePair`2[[System.String, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[PdfSharp.Pdf.PdfItem, PdfSharp, Version=0.1.3.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Collections.IEnumerable

Inheritance ObjectPdfItemPdfObjectPdfDictionaryPdfAcroField
Implements ICloneable, IEnumerable<KeyValuePair<String, PdfItem>>, IEnumerable

Properties

Name

Gets the name of this field.

public string Name { get; set; }

Property Value

String

AlternateName

Gets the alternative Name of the Field (/TU)

public string AlternateName { get; set; }

Property Value

String

MappingName

Gets the mapping Name of the Field (/TM)

public string MappingName { get; set; }

Property Value

String

FullyQualifiedName

Gets the fully qualified name of this field, that is: “parent-name.field-name”

If the field has no parent, this is equal to PdfAcroField.Name

public string FullyQualifiedName { get; }

Property Value

String

Parent

Gets the Parent of this field or null, if the field has no parent

public PdfAcroField Parent { get; internal set; }

Property Value

PdfAcroField

Flags

Gets the field flags of this instance.

public PdfAcroFieldFlags Flags { get; }

Property Value

PdfAcroFieldFlags

Font

Gets or sets the font used to draw the text of the field.

public XFont Font { get; set; }

Property Value

XFont

DeterminedFontSize

Gets the font size that was obtained by analyzing the Fields’ content-stream.

public double DeterminedFontSize { get; internal set; }

Property Value

Double

ForeColor

Gets or sets the foreground color of the field.

public XColor ForeColor { get; set; }

Property Value

XColor

Value

Gets or sets the value of the field.

public PdfItem Value { get; set; }

Property Value

PdfItem

DefaultValue

Gets or sets the default value of the field.

public PdfItem DefaultValue { get; set; }

Property Value

PdfItem

TextAlign

Gets or sets the alignment for the text of this field.

public TextAlignment TextAlign { get; set; }

Property Value

TextAlignment

ReadOnly

Gets or sets a value indicating whether the field is read only.

public bool ReadOnly { get; set; }

Property Value

Boolean

Item

public PdfAcroField Item { get; }

Property Value

PdfAcroField

HasKids

Indicates whether the field has child fields and/or annotations.

public bool HasKids { get; }

Property Value

Boolean

HasChildFields

Indicates whether the field has child fields.

public bool HasChildFields { get; }

Property Value

Boolean

DescendantNames

Caution

Use GetDescendantNames


Gets the names of all descendants of this field.

public String[] DescendantNames { get; }

Property Value

String[]

Fields

Gets the collection of fields within this field.

public PdfAcroFieldCollection Fields { get; }

Property Value

PdfAcroFieldCollection

Annotations

Gets the annotations for this field. The elements in this list are of type PdfWidgetAnnotation.

public PdfAnnotationArray Annotations { get; }

Property Value

PdfAnnotationArray

Elements

Gets the dictionary containing the elements of this dictionary.

public DictionaryElements Elements { get; }

Property Value

DictionaryElements

Stream

Gets or sets the PDF stream belonging to this dictionary. Returns null if the dictionary has no stream. To create the stream, call the CreateStream function.

public PdfStream Stream { get; set; }

Property Value

PdfStream

Owner

Gets the PdfDocument this object belongs to.

public PdfDocument Owner { get; }

Property Value

PdfDocument

IsIndirect

Indicates whether the object is an indirect object.

public bool IsIndirect { get; }

Property Value

Boolean

Internals

Gets the PdfInternals object of this document, that grants access to some internal structures which are not part of the public interface of PdfDocument.

public PdfObjectInternals Internals { get; }

Property Value

PdfObjectInternals

Reference

Gets the indirect reference of this object. If the value is null, this object is a direct object.

public PdfReference Reference { get; internal set; }

Property Value

PdfReference

ReferenceNotNull

Gets the indirect reference of this object. Throws if it is null.

public PdfReference ReferenceNotNull { get; }

Property Value

PdfReference

Exceptions

InvalidOperationException
The indirect reference must be not null here.

Methods

GetValue(String)

Gets a child field by name.

protected PdfAcroField GetValue(string name)

Parameters

name String

Returns

PdfAcroField

GetDescendantNames()

Gets the names of all descendants of this field.

public String[] GetDescendantNames()

Returns

String[]

GetAppearanceNames()

Gets the names of all appearance dictionaries of this AcroField.

public String[] GetAppearanceNames()

Returns

String[]

GetDescendantNames(List`1&, String)

internal void GetDescendantNames(List`1& names, string partialName)

Parameters

names List`1&

partialName String

AddAnnotation(Action<PdfWidgetAnnotation>)

Adds a new Annotation to this field.

public PdfWidgetAnnotation AddAnnotation(Action<PdfWidgetAnnotation> configure)

Parameters

configure Action<PdfWidgetAnnotation>
A method that is used to configure the Annotation

Returns

PdfWidgetAnnotation
The created and configured Annotation

Exceptions

ArgumentNullException

RemoveAnnotation(PdfWidgetAnnotation)

Removed the specified annotation from this field

public bool RemoveAnnotation(PdfWidgetAnnotation annotation)

Parameters

annotation PdfWidgetAnnotation
The annotation to remove

Returns

Boolean
true, if the annotation was removed, false otherwise

AddChild(PdfAcroField)

Adds the specified PdfAcroField to the list of child-fields of this field

public void AddChild(PdfAcroField childField)

Parameters

childField PdfAcroField

Delete()

Deletes this field, all child-fields and associated annotations from the document

public void Delete()

DetermineAppearance()

Tries to determine the Appearance of the Field by checking elements of its dictionary

protected void DetermineAppearance()

DetermineFontFromContent(Byte[])

Attempts to determine the font, font-size and fore-color of this AcroField

protected void DetermineFontFromContent(Byte[] contentBytes)

Parameters

contentBytes Byte[]

IsStandardFont(String, XFontStyleEx&)

Gets a value indicating whether the specified font name is one of the predefined font-names for pdf documents

protected static bool IsStandardFont(string fontName, XFontStyleEx& fontStyle)

Parameters

fontName String
Name of the font to check

fontStyle XFontStyleEx&
Receives the font-style of the checked-font

Returns

Boolean

SetXFormFont(XForm)

Adds the font of the current AcroField to the specified XForm object

protected void SetXFormFont(XForm form)

Parameters

form XForm

PrepareForSave()

internal void PrepareForSave()

Flatten()

internal void Flatten()

RenderAppearance()

Must be overridden by subclasses

protected void RenderAppearance()

RenderAppearanceToPage()

Renders the widget-appearances of this field directly onto the page.
Used by the method.

protected void RenderAppearanceToPage()

RenderContentStream(PdfPage, PdfDictionary, PdfRectangle)

Renders the contents of the supplied Stream to the Page at the position specified by the provided Rectangle

protected void RenderContentStream(PdfPage page, PdfDictionary streamDict, PdfRectangle rect)

Parameters

page PdfPage
Page to render the content onto

streamDict PdfDictionary
A PdfDictionary containing a stream with drawing-operators and associated resources

rect PdfRectangle