SetStructElemSpaceBefore

Tagged PDF, Accessibility

Description

Sets the /SpaceBefore attribute (Layout attribute owner) on the structure element currently open on the tag stack. The value specifies the amount of space to add before the block-level element — analogous to CSS margin-top or padding-top. Equivalent to calling AddTagAttribute with Owner=Layout, Name=SpaceBefore, and the numeric value as a string.

Syntax

Delphi

function TPDFlib.SetStructElemSpaceBefore(Space: Double): Integer;

ActiveX

Function PDFlib::SetStructElemSpaceBefore(Space As Double) As Long

DLL

int DLSetStructElemSpaceBefore(int InstanceID, double Space);

Parameters

SpaceSpace before the element in default user space units (points, 1/72 inch). Must be a non-negative value. A value of 0 means no extra space before the element.

Return value

Returns 1 on success. Returns 0 if no document is open or no tag is currently open on the tag stack.

Remarks

Call this function after BeginTag or BeginTagEx and before EndTag. The /SpaceBefore attribute is defined in ISO 32000-1 §14.8.5.4.2 (Layout attribute owner, Table 340).

Layout attributes (SpaceBefore, SpaceAfter, StartIndent, EndIndent) are advisory: they describe the intended visual layout for re-flow and export engines (for example, when a PDF is reflowed to HTML or EPUB). They do not affect the rendered appearance of the PDF itself. Providing accurate layout attributes improves the quality of reflowed output from accessibility tools.

Example

// Tag a heading with extra space above it
PDFlib.BeginTag('H1', '', '', '');
PDFlib.SetStructElemSpaceBefore(12.0);  // 12 pt above the heading
PDFlib.DrawText('Introduction', 72, 700);
PDFlib.EndTag;

See also

SetStructElemSpaceAfter, SetStructElemStartIndent, SetStructElemWritingMode, AddTagAttribute