Scale

class Scale

A ratio of the size of an object as displayed on a document page to the size of a corresponding real-world object. Scale objects are used for measurement annotations. This class is immutable - you must create a new Scale object if you want to change any of the members.

Constructors

Link copied to clipboard
constructor(@FloatRange(from = 9.999999747378752E-6) valueFrom: Float, unitFrom: Scale.UnitFrom, @FloatRange(from = 9.999999747378752E-6) valueTo: Float, unitTo: Scale.UnitTo)

Creates an instance of a measurement Scale object.

Types

Link copied to clipboard
object Companion

Companion object containing factory methods for creating Scale instances.

Link copied to clipboard

Units available for the source scale value.

Link copied to clipboard

Units available for the target scale value.

Properties

Link copied to clipboard

The user-provided string description for the source value, or null if not provided.

Link copied to clipboard

String representation of the source scale value. Returns the user-provided fractional input if available, otherwise formats as decimal.

Link copied to clipboard

The user-provided string description for the target value, or null if not provided.

Link copied to clipboard

String representation of the target scale value. Returns the user-provided fractional input if available, otherwise formats as decimal.

Link copied to clipboard

The unit for the source scale value (distance on the PDF page).

Link copied to clipboard

The unit for the target scale value (distance in the real world).

Link copied to clipboard

Value in specified units for the source scale. i.e. distance on the PDF page

Link copied to clipboard

Value in specified units for the target scale. i.e. distance in the real world.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

Equality is based on the display string, which includes user-provided descriptions (such as fractional input) or formatted float values. This means that two Scale objects with numerically equivalent values but different string representations (e.g., "3/4" vs "0.75") will not be considered equal. This is intentional, as users may expect the exact input to be preserved. For numeric equivalence, use numericEquals instead.

Link copied to clipboard
open override fun hashCode(): Int

Returns a hash code value for this Scale based on its string representation.

Link copied to clipboard

Compares this Scale to another for numeric equivalence, ignoring string representations. Returns true if the values and units are equal, regardless of input format. For example, Scale.fromStrings("3/4", IN, "1", FT) and Scale(0.75f, IN, 1f, FT) are numerically equal but not equal according to equals.

Link copied to clipboard
open override fun toString(): String

Returns a string representation of this Scale in the format "fromValue unitFrom : toValue unitTo".