Class ZoneBuilder
- Namespace
- SecureExchangesSDK.Helpers
- Assembly
- SecureExchangesSDK.NetCore.dll
Helper class for creating signature zones on a PDF document. Initializes once per PDF and caches page dimensions for optimal performance.
public class ZoneBuilder : IDisposable
- Inheritance
-
ZoneBuilder
- Implements
- Inherited Members
- Extension Methods
Remarks
Use this class when creating multiple zones on the same PDF to avoid repeatedly opening the file. Implements IDisposable for proper resource cleanup.
Constructors
ZoneBuilder(byte[], bool)
Initializes a new instance of the ZoneBuilder class. Opens the PDF document from a byte array and prepares for zone creation.
public ZoneBuilder(byte[] fileBytes, bool isPki = true)
Parameters
fileBytesbyte[]The bytes of the PDF file
isPkiboolWhether the signature process uses PKI (true by default)
Exceptions
- ArgumentException
Thrown when the byte array is null or empty
ZoneBuilder(string, bool)
Initializes a new instance of the ZoneBuilder class. Opens the PDF document from a file path and prepares for zone creation.
public ZoneBuilder(string filePath, bool isPki = true)
Parameters
filePathstringThe full path to the PDF file
isPkiboolWhether the signature process uses PKI (true by default)
Exceptions
- ArgumentException
Thrown when the file path is null or empty
- FileNotFoundException
Thrown when the PDF file does not exist
Properties
IsPki
Gets a value indicating whether the signature process uses PKI (Public Key Infrastructure) mode. When true, additional zone types like TextArea and OptionList are available.
public bool IsPki { get; }
Property Value
PageCount
Gets the total number of pages in the PDF document.
public int PageCount { get; }
Property Value
Methods
CreateFieldCheckBoxZone(int, string, float, float, bool, bool, bool)
Creates a checkbox zone on the PDF document.
public SignZoneDetails CreateFieldCheckBoxZone(int page, string fieldName, float x, float y, bool isChecked = false, bool required = false, bool requiredFocus = false)
Parameters
Returns
CreateFieldDateSignZone(int, string, float, float, float, float, float)
Creates a date signature zone (auto-filled with signature date) on the PDF document.
public SignZoneDetails CreateFieldDateSignZone(int page, string fieldName, float x, float y, float width, float height, float fontSize = 12)
Parameters
Returns
CreateFieldDateZone(int, string, float, float, float, float, float, bool)
Creates a date picker zone on the PDF document.
public SignZoneDetails CreateFieldDateZone(int page, string fieldName, float x, float y, float width, float height, float fontSize = 12, bool required = true)
Parameters
Returns
CreateFieldDropdownZone(int, string, float, float, float, float, string[], string, float, bool)
Creates a dropdown zone on the PDF document.
public SignZoneDetails CreateFieldDropdownZone(int page, string fieldName, float x, float y, float width, float height, string[] options, string selectedValue = null, float fontSize = 12, bool required = false)
Parameters
pageintfieldNamestringxfloatyfloatwidthfloatheightfloatoptionsstring[]selectedValuestringfontSizefloatrequiredbool
Returns
Exceptions
- NotSupportedException
Thrown when isPki is false.
- ArgumentException
Thrown when options is null or empty.
CreateFieldInitialZone(int, string, float, float, float, float)
Creates an initials zone on the PDF document.
public SignZoneDetails CreateFieldInitialZone(int page, string fieldName, float x, float y, float width, float height)
Parameters
Returns
CreateFieldNumberZone(int, string, float, float, float, float, int, float, bool)
Creates a number input zone on the PDF document.
public SignZoneDetails CreateFieldNumberZone(int page, string fieldName, float x, float y, float width, float height, int defaultValue, float fontSize = 12, bool required = true)
Parameters
pageintfieldNamestringxfloatyfloatwidthfloatheightfloatdefaultValueintfontSizefloatrequiredbool
Returns
CreateFieldOptionListZone(int, string, float, float, float, float, string[], string[], bool, bool)
Creates an option list (select) zone on the PDF document.
public SignZoneDetails CreateFieldOptionListZone(int page, string fieldName, float x, float y, float width, float height, string[] options, string[] selectedValues = null, bool multiSelect = false, bool required = false)
Parameters
pageintfieldNamestringxfloatyfloatwidthfloatheightfloatoptionsstring[]selectedValuesstring[]multiSelectboolrequiredbool
Returns
Exceptions
- NotSupportedException
Thrown when isPki is false.
- ArgumentException
Thrown when options is null or empty.
CreateFieldRadioZone(int, string, float, float, string, bool)
Creates a radio button zone on the PDF document.
public SignZoneDetails CreateFieldRadioZone(int page, string fieldName, float x, float y, string groupId, bool isSelected = false)
Parameters
Returns
CreateFieldSignZone(int, string, float, float, float, float)
Creates a signature zone on the PDF document.
public SignZoneDetails CreateFieldSignZone(int page, string fieldName, float x, float y, float width, float height)
Parameters
Returns
CreateFieldTextAreaZone(int, string, float, float, float, float, string, float, bool)
Creates a text area (multiline text) zone on the PDF document.
public SignZoneDetails CreateFieldTextAreaZone(int page, string fieldName, float x, float y, float width, float height, string defaultValue = "", float fontSize = 12, bool required = false)
Parameters
pageintfieldNamestringxfloatyfloatwidthfloatheightfloatdefaultValuestringfontSizefloatrequiredbool
Returns
Exceptions
- NotSupportedException
Thrown when isPki is false.
CreateFieldTextZone(int, string, float, float, float, float, string, float, bool)
Creates a text input zone on the PDF document.
public SignZoneDetails CreateFieldTextZone(int page, string fieldName, float x, float y, float width, float height, string defaultValue = "", float fontSize = 12, bool required = true)
Parameters
pageintfieldNamestringxfloatyfloatwidthfloatheightfloatdefaultValuestringfontSizefloatrequiredbool
Returns
Dispose()
Releases all resources used by the ZoneBuilder.
public void Dispose()
Dispose(bool)
Releases the unmanaged resources and optionally releases the managed resources.
protected virtual void Dispose(bool disposing)
Parameters
disposingbool
~ZoneBuilder()
Finalizer for the ZoneBuilder class.
protected ~ZoneBuilder()
GetPageDimensions(int)
Gets the page dimensions for a specific page, using cached values when available.
public PdfPageDimensions GetPageDimensions(int page)
Parameters
pageintPage number (1-based)
Returns
- PdfPageDimensions
Page dimensions in points (72 DPI)