{"record":{"id":"2063fea3896cfeab","repo":"QuestPDF/QuestPDF","slug":"the-minimum-height-cannot-be-greater-than-the-maxi","errorCode":null,"errorMessage":"The minimum height cannot be greater than the maximum height.","messagePattern":"The minimum height cannot be greater than the maximum height\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/dotnet/library/QuestPDF/Fluent/ConstrainedExtensions.cs","lineNumber":81,"sourceCode":"            return element.ConstrainedWidth(max: value);\n        }\n        \n        #endregion\n        \n        #region Height\n        \n        private static IContainer ConstrainedHeight(this IContainer element, float? min = null, float? max = null)\n        {\n            var constrained = element as Constrained ?? new Constrained();\n            \n            if (min < 0)\n                throw new ArgumentOutOfRangeException(nameof(min), \"The minimum height cannot be negative.\");\n            \n            if (max < 0)\n                throw new ArgumentOutOfRangeException(nameof(max), \"The maximum height cannot be negative.\");\n            \n            if (min > max)\n                throw new ArgumentOutOfRangeException(nameof(min), \"The minimum height cannot be greater than the maximum height.\");\n            \n            if (min.HasValue) \n                constrained.MinHeight = min;\n            \n            if (max.HasValue)\n                constrained.MaxHeight = max;\n            \n            return element.Element(constrained);\n        }\n        \n        /// <summary>\n        /// Sets the exact height of its content.\n        /// <a href=\"https://www.questpdf.com/api-reference/height.html\">Learn more</a>\n        /// </summary>\n        /// <returns>The container with the specified exact height.</returns>\n        public static IContainer Height(this IContainer element, float value, Unit unit = Unit.Point)\n        {\n            value = value.ToPoints(unit);","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/QuestPDF/QuestPDF/blob/43ab12559671556e10a6a0a5afe542c919f48a21/src/dotnet/library/QuestPDF/Fluent/ConstrainedExtensions.cs#L63-L99","documentation":"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.","triggerScenarios":"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.","commonSituations":"Swapped min/max arguments; data-driven bounds where the dynamic range collapses and inverts; copy-paste from a context with different magnitudes.","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."],"exampleFix":"// before\ncontainer.Height(min: 200, max: 100);\n// after\ncontainer.Height(min: 100, max: 200);","handlingStrategy":"validation","validationCode":"if (minHeight > maxHeight)\n    (minHeight, maxHeight) = (maxHeight, minHeight); // or throw explicitly\ncontainer.Height(minHeight, maxHeight);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure min <= max whenever both height bounds are set.","Mind argument order in Height(min, max).","Guard computed bounds against range collapse/inversion."],"tags":["questpdf","constrained","height","validation","fluent"],"backgroundTag":null,"analyzedSha":"43ab12559671556e10a6a0a5afe542c919f48a21","analyzedAt":"2026-08-13T17:02:41.303Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}