QuestPDF/QuestPDF · error · ArgumentOutOfRangeException
The minimum height cannot be greater than the maximum height
Error message
The minimum height cannot be greater than the maximum height.
What it means
A minimum height cannot exceed the maximum height; otherwise the constraint is unsatisfiable. The validator throws ArgumentOutOfRangeException when both bounds are provided and min > max.
Source
Thrown at src/dotnet/library/QuestPDF/Fluent/ConstrainedExtensions.cs:81
return element.ConstrainedWidth(max: value);
}
#endregion
#region Height
private static IContainer ConstrainedHeight(this IContainer element, float? min = null, float? max = null)
{
var constrained = element as Constrained ?? new Constrained();
if (min < 0)
throw new ArgumentOutOfRangeException(nameof(min), "The minimum height cannot be negative.");
if (max < 0)
throw new ArgumentOutOfRangeException(nameof(max), "The maximum height cannot be negative.");
if (min > max)
throw new ArgumentOutOfRangeException(nameof(min), "The minimum height cannot be greater than the maximum height.");
if (min.HasValue)
constrained.MinHeight = min;
if (max.HasValue)
constrained.MaxHeight = max;
return element.Element(constrained);
}
/// <summary>
/// Sets the exact height of its content.
/// <a href="https://www.questpdf.com/api-reference/height.html">Learn more</a>
/// </summary>
/// <returns>The container with the specified exact height.</returns>
public static IContainer Height(this IContainer element, float value, Unit unit = Unit.Point)
{
value = value.ToPoints(unit);View on GitHub (pinned to 43ab125596)
Solutions
- Ensure min <= max whenever both are specified.
- When bounds are computed, clamp or swap so min never exceeds max.
- Double-check argument order in the combined Height(min, max) call.
Example fix
// before container.Height(min: 200, max: 100); // after container.Height(min: 100, max: 200);
Defensive patterns
Strategy: validation
Validate before calling
if (minHeight > maxHeight)
(minHeight, maxHeight) = (maxHeight, minHeight); // or throw explicitly
container.Height(minHeight, maxHeight); Prevention
- Ensure min <= max whenever both height bounds are set.
- Mind argument order in Height(min, max).
- Guard computed bounds against range collapse/inversion.
When it happens
Trigger: Calling .Height(min, max) (or separately setting MinHeight then MaxHeight) with min greater than max, e.g., inverted arguments or computed bounds that crossed over.
Common situations: Swapped min/max arguments; data-driven bounds where the dynamic range collapses and inverts; copy-paste from a context with different magnitudes.
Related errors
- The minimum height cannot be negative.
- The maximum height cannot be negative.
- The minimum width cannot be negative.
- The maximum width cannot be negative.
- The minimum width cannot be greater than the maximum width.
AI-assisted analysis of QuestPDF/QuestPDF@43ab125596 (2026-08-13).
Data as JSON: /api/errors/2063fea3896cfeab.
Report an issue: GitHub.