From 0ccc8cc2366a5f49100e32c71a963e10a81aef14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zi=C4=85bek?= Date: Mon, 11 Oct 2021 23:01:26 +0200 Subject: [PATCH] Improved the DocumentLayoutException message --- QuestPDF/Drawing/DocumentGenerator.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/QuestPDF/Drawing/DocumentGenerator.cs b/QuestPDF/Drawing/DocumentGenerator.cs index 364c98c..cd1718d 100644 --- a/QuestPDF/Drawing/DocumentGenerator.cs +++ b/QuestPDF/Drawing/DocumentGenerator.cs @@ -81,7 +81,7 @@ namespace QuestPDF.Drawing if (currentPage >= documentMetadata.DocumentLayoutExceptionThreshold) { canvas.EndDocument(); - throw new DocumentLayoutException("Composed layout generates infinite document."); + ThrowLayoutException(); } if (spacePlan is FullRender) @@ -94,7 +94,12 @@ namespace QuestPDF.Drawing void ThrowLayoutException() { - throw new DocumentLayoutException("Composed layout generates infinite document."); + throw new DocumentLayoutException( + $"Composed layout generates infinite document. This may happen in two cases. " + + $"1) Your document and its layout configuration is correct but the content takes more than {documentMetadata.DocumentLayoutExceptionThreshold} pages. " + + $"In this case, please increase the value {nameof(DocumentMetadata)}.{nameof(DocumentMetadata.DocumentLayoutExceptionThreshold)} property configured in the {nameof(IDocument.GetMetadata)} method. " + + $"2) The layout configuration of your document is invalid. Some of the elements require more space than is provided." + + $"Please analyze your documents structure to detect this element and fix its size constraints."); } }