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
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
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
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
Link copied to clipboard
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
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