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
Output (example):
<p>Random: 0.742</p>
Random Integer Range
Random Selection
Random Percentage
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().