QuestPDF/QuestPDF · error · ArgumentOutOfRangeException
The bottom-left corner radius cannot be negative.
Error message
The bottom-left corner radius cannot be negative.
What it means
The private CornerRadius(IContainer, float? topLeft, float? topRight, float? bottomRight, float? bottomLeft) method throws ArgumentOutOfRangeException when bottomLeft is negative. Public methods CornerRadius(float), CornerRadiusBottomLeft(float), and the uniform overload route through this guard.
Source
Thrown at src/dotnet/library/QuestPDF/Fluent/StyledBoxExtensions.cs:172
#endregion
#region Corner Radius
private static IContainer CornerRadius(this IContainer element, float? topLeft = null, float? topRight = null, float? bottomRight = null, float? bottomLeft = null)
{
var styledBox = element as StyledBox ?? new StyledBox();
if (topLeft < 0)
throw new ArgumentOutOfRangeException(nameof(topLeft), "The top-left corner radius cannot be negative.");
if (topRight < 0)
throw new ArgumentOutOfRangeException(nameof(topRight), "The top-right corner radius cannot be negative.");
if (bottomRight < 0)
throw new ArgumentOutOfRangeException(nameof(bottomRight), "The bottom-right corner radius cannot be negative.");
if (bottomLeft < 0)
throw new ArgumentOutOfRangeException(nameof(bottomLeft), "The bottom-left corner radius cannot be negative.");
if (topLeft.HasValue)
styledBox.BorderRadiusTopLeft = topLeft.Value;
if (topRight.HasValue)
styledBox.BorderRadiusTopRight = topRight.Value;
if (bottomRight.HasValue)
styledBox.BorderRadiusBottomRight = bottomRight.Value;
if (bottomLeft.HasValue)
styledBox.BorderRadiusBottomLeft = bottomLeft.Value;
return element.Element(styledBox);
}
/// <summary>
/// Applies a uniform corner radius to all corners of the container with the specified value and unit.View on GitHub (pinned to 43ab125596)
Solutions
- Clamp with Math.Max(0, value) before the call.
- Fix the upstream computation.
- Validate externally sourced values before styling.
Example fix
// before container.CornerRadiusBottomLeft(radius); // after container.CornerRadiusBottomLeft(Math.Max(0, radius));
Defensive patterns
Strategy: validation
Validate before calling
var safeRadius = Math.Max(0, bottomLeft); container.CornerRadiusBottomLeft(safeRadius);
Type guard
static bool IsValidRadius(float value) => value >= 0;
Prevention
- Clamp radius values with Math.Max(0, value) before corner-radius calls.
- Guard config-driven values at the boundary.
- Audit computed radius expressions for negatives.
When it happens
Trigger: Calling container.CornerRadiusBottomLeft(-5), container.CornerRadius(-2), or the uniform overload with a negative value — any negative bottom-left radius.
Common situations: Computed styling from user data that goes negative; theme configs with sentinel defaults; layout subtraction errors.
Related errors
- The top-left corner radius cannot be negative.
- The top-right corner radius cannot be negative.
- The bottom-right corner radius cannot be negative.
- The top border cannot be negative.
- The bottom border cannot be negative.
AI-assisted analysis of QuestPDF/QuestPDF@43ab125596 (2026-08-13).
Data as JSON: /api/errors/788ad254e5808d00.
Report an issue: GitHub.