Package com.itextpdf.forms.form.renderer
Class AbstractFormFieldRenderer
- java.lang.Object
-
- com.itextpdf.layout.renderer.AbstractRenderer
-
- com.itextpdf.layout.renderer.BlockRenderer
-
- com.itextpdf.forms.form.renderer.AbstractFormFieldRenderer
-
- All Implemented Interfaces:
IPropertyContainer
,IRenderer
- Direct Known Subclasses:
AbstractTextFieldRenderer
,CheckBoxRenderer
,RadioRenderer
public abstract class AbstractFormFieldRenderer extends BlockRenderer
AbstractBlockRenderer
for form fields.
-
-
Field Summary
Fields Modifier and Type Field Description protected IRenderer
flatRenderer
The flat renderer.-
Fields inherited from class com.itextpdf.layout.renderer.AbstractRenderer
childRenderers, EPS, flushed, INF, isLastRendererForModelElement, modelElement, occupiedArea, OVERLAP_EPSILON, parent, positionedRenderers, properties
-
-
Constructor Summary
Constructors Constructor Description AbstractFormFieldRenderer(IFormField modelElement)
Creates a newAbstractFormFieldRenderer
instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
adjustFieldLayout(LayoutContext layoutContext)
Adjusts the field layout.protected void
applyAccessibilityProperties(PdfFormField formField, PdfDocument pdfDocument)
Applies the accessibility properties to the form field.protected abstract void
applyAcroField(DrawContext drawContext)
Applies the AcroField widget.protected abstract IRenderer
createFlatRenderer()
Creates the flat renderer instance.void
draw(DrawContext drawContext)
Flushes the renderer subtree contents, i.e.void
drawChildren(DrawContext drawContext)
Performs the drawing operation for allchildren
of this renderer.protected PdfConformance
getConformance(PdfDocument document)
Gets the conformance.java.lang.String
getDefaultValue()
Gets the default value of the form field.protected java.lang.String
getLang()
Gets the accessibility language usingIAccessibleElement.getAccessibilityProperties()
.MinMaxWidth
getMinMaxWidth()
Calculates min and max width values for current renderer.protected java.lang.String
getModelId()
Gets the model id.boolean
isFlatten()
Checks if form fields need to be flattened.protected boolean
isLayoutBasedOnFlatRenderer()
Determines, whether the layout is based in the renderer itself or flat renderer.protected boolean
isRendererFit(float availableWidth, float availableHeight)
Checks if the renderer fits a certain width and height.LayoutResult
layout(LayoutContext layoutContext)
This method simulates positioning of the renderer, including all of its children, and returns theLayoutResult
, representing the layout result, including occupied area, status, i.e.private void
processLangAttribute()
protected void
writeAcroFormFieldLangAttribute(PdfDocument pdfDoc)
Sets the form accessibility language identifier of the form element in case the document is tagged.-
Methods inherited from class com.itextpdf.layout.renderer.BlockRenderer
applyRotationLayout, applyVerticalAlignment, beginRotationIfApplied, createOverflowRenderer, createRotationTransformInsideOccupiedArea, createSplitRenderer, endRotationIfApplied, getMinMaxWidth, getOccupiedAreaBBox, getResolvedFont
-
Methods inherited from class com.itextpdf.layout.renderer.AbstractRenderer
addAllProperties, addChild, alignChildHorizontally, allowLastYLineRecursiveExtraction, applyAbsolutePosition, applyAction, applyBorderBox, applyBorderBox, applyDestination, applyDestinationsAndAnnotation, applyLinkAnnotation, applyMargins, applyMargins, applyPaddings, applyPaddings, applyRelativePositioningTranslation, beginElementOpacityApplying, beginTransformationIfApplied, calculateAbsolutePdfBBox, calculateBBox, calculateShiftToPositionBBoxOfPointsAt, clipBackgroundArea, clipBackgroundArea, clipBorderArea, createXObject, deleteOwnProperty, deleteProperty, drawBackground, drawBorder, endElementOpacityApplying, endTransformationIfApplied, getBackgroundArea, getBorderAreaBBox, getBorderRadii, getBorders, getChildRenderers, getDefaultProperty, getFirstYLineRecursively, getInnerAreaBBox, getLastYLineRecursively, getMargins, getModelElement, getOccupiedArea, getOwnProperties, getOwnProperty, getPaddings, getParent, getProperty, getProperty, getPropertyAsBoolean, getPropertyAsColor, getPropertyAsFloat, getPropertyAsFloat, getPropertyAsFont, getPropertyAsInteger, getPropertyAsTransparentColor, getPropertyAsUnitValue, hasAbsoluteUnitValue, hasOwnOrModelProperty, hasOwnProperty, hasProperty, hasRelativeUnitValue, initElementAreas, isAbsolutePosition, isBorderBoxSizing, isFirstOnRootArea, isFixedLayout, isFlushed, isKeepTogether, isNotFittingHeight, isNotFittingLayoutArea, isNotFittingWidth, isOverflowFit, isOverflowProperty, isOverflowProperty, isOverflowProperty, isPositioned, isRelativePosition, isStaticLayout, move, rectangleToPointsList, retrieveHeight, retrieveMaxHeight, retrieveMaxWidth, retrieveMinHeight, retrieveMinWidth, retrieveResolvedDeclaredHeight, retrieveUnitValue, retrieveUnitValue, retrieveWidth, setBorders, setMinMaxWidthBasedOnFixedWidth, setParent, setProperty, toString, transformPoints, updateHeight, updateHeightsOnSplit, updateMaxHeight, updateMinHeight, updateWidth
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.itextpdf.layout.renderer.IRenderer
getNextRenderer
-
-
-
-
Field Detail
-
flatRenderer
protected IRenderer flatRenderer
The flat renderer.
-
-
Constructor Detail
-
AbstractFormFieldRenderer
AbstractFormFieldRenderer(IFormField modelElement)
Creates a newAbstractFormFieldRenderer
instance.- Parameters:
modelElement
- the model element
-
-
Method Detail
-
isFlatten
public boolean isFlatten()
Checks if form fields need to be flattened.- Returns:
- true, if fields need to be flattened.
-
getDefaultValue
public java.lang.String getDefaultValue()
Gets the default value of the form field.- Returns:
- the default value of the form field.
-
layout
public LayoutResult layout(LayoutContext layoutContext)
This method simulates positioning of the renderer, including all of its children, and returns theLayoutResult
, representing the layout result, including occupied area, status, i.e. if there was enough place to fit the renderer subtree, etc.LayoutResult
can be extended to return custom layout results for custom elements, e.g.TextRenderer
usesTextLayoutResult
as its result. This method can be called standalone to learn how much area the renderer subtree needs, or can be called beforeIRenderer.draw(DrawContext)
, to prepare the renderer to be flushed to the output stream.- Specified by:
layout
in interfaceIRenderer
- Overrides:
layout
in classBlockRenderer
- Parameters:
layoutContext
- the description of layout area and any other additional information- Returns:
- result of the layout process
-
draw
public void draw(DrawContext drawContext)
Flushes the renderer subtree contents, i.e. draws itself on canvas, adds necessary objects to thePdfDocument
etc.- Specified by:
draw
in interfaceIRenderer
- Overrides:
draw
in classBlockRenderer
- Parameters:
drawContext
- contains thePdfDocument
to which the renderer subtree if flushed, thePdfCanvas
on which the renderer subtree is drawn and other additional parameters needed to perform drawing
-
getMinMaxWidth
public MinMaxWidth getMinMaxWidth()
Calculates min and max width values for current renderer.- Overrides:
getMinMaxWidth
in classBlockRenderer
- Returns:
- instance of
MinMaxWidth
-
drawChildren
public void drawChildren(DrawContext drawContext)
Performs the drawing operation for allchildren
of this renderer.- Overrides:
drawChildren
in classAbstractRenderer
- Parameters:
drawContext
- the context (canvas, document, etc) of this drawing operation.
-
applyAccessibilityProperties
protected void applyAccessibilityProperties(PdfFormField formField, PdfDocument pdfDocument)
Applies the accessibility properties to the form field.- Parameters:
formField
- the form field to which the accessibility properties should be appliedpdfDocument
- the document to which the form field belongs
-
adjustFieldLayout
protected abstract void adjustFieldLayout(LayoutContext layoutContext)
Adjusts the field layout.- Parameters:
layoutContext
- layout context
-
createFlatRenderer
protected abstract IRenderer createFlatRenderer()
Creates the flat renderer instance.- Returns:
- the renderer instance.
-
applyAcroField
protected abstract void applyAcroField(DrawContext drawContext)
Applies the AcroField widget.- Parameters:
drawContext
- the draw context
-
getModelId
protected java.lang.String getModelId()
Gets the model id.- Returns:
- the model id.
-
isRendererFit
protected boolean isRendererFit(float availableWidth, float availableHeight)
Checks if the renderer fits a certain width and height.- Parameters:
availableWidth
- the available widthavailableHeight
- the available height- Returns:
- true, if the renderer fits.
-
getLang
protected java.lang.String getLang()
Gets the accessibility language usingIAccessibleElement.getAccessibilityProperties()
.- Returns:
- the accessibility language.
-
getConformance
protected PdfConformance getConformance(PdfDocument document)
Gets the conformance. If the conformance is not set, the conformance of the document is used.- Parameters:
document
- the document- Returns:
- the conformance or null if the conformance is not set.
-
isLayoutBasedOnFlatRenderer
protected boolean isLayoutBasedOnFlatRenderer()
Determines, whether the layout is based in the renderer itself or flat renderer.- Returns:
true
if layout is based on flat renderer, false otherwise.
-
writeAcroFormFieldLangAttribute
protected void writeAcroFormFieldLangAttribute(PdfDocument pdfDoc)
Sets the form accessibility language identifier of the form element in case the document is tagged.- Parameters:
pdfDoc
- the document which contains form field
-
processLangAttribute
private void processLangAttribute()
-
-