Skip to main content Link Search Menu Expand Document (external link)

random() : Random Number


On this page

Summary

Generate a random number between 0 and 1.

Signature

random()

Parameters

None.


Returns

Type: Double

A random value between 0.0 (inclusive) and 1.0 (exclusive).


Examples

Basic Random

<p>Random: </p>

Output (example):

<p>Random: 0.742</p>

Random Integer Range

<!-- Random integer from 1 to 10 -->
<p>Random (1-10): </p>

Random Selection

<!-- Randomly select from array -->
<p>Selected: </p>

Random Percentage

<p>Random percentage: %</p>

Notes

  • Returns value ≥ 0 and < 1
  • Different value each time (non-deterministic)
  • Warning: PDFs are static documents - random values are generated once at template processing time
  • Not cryptographically secure
  • For range [min, max]: random() * (max - min) + min
  • For integer range: floor(random() * (max - min + 1)) + min

Important

PDF documents are static - random values are calculated during document generation and remain fixed in the output. If you need consistent values across multiple document generations, provide them in your model data instead of using random().


See Also