Browse Source

Synced to 2021.12-alpha0

Marcin Ziąbek 4 years ago
parent
commit
77b8f04659
2 changed files with 16 additions and 9 deletions
  1. 9 2
      QuestPDF.ReportSample/Tests.cs
  2. 7 7
      QuestPDF/Drawing/DocumentGenerator.cs

+ 9 - 2
QuestPDF.ReportSample/Tests.cs

@@ -22,11 +22,18 @@ namespace QuestPDF.ReportSample
         }
         
         [Test] 
-        public void GenerateAndShow()
+        public void GenerateAndShowPdf()
         {
             var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"test_result.pdf");
             Report.GeneratePdf(path);
-            
+            Process.Start("explorer.exe", path);
+        }
+        
+        [Test] 
+        public void GenerateAndShowXps()
+        {
+            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"test_result.xps");
+            Report.GenerateXps(path);
             Process.Start("explorer.exe", path);
         }
         

+ 7 - 7
QuestPDF/Drawing/DocumentGenerator.cs

@@ -113,16 +113,16 @@ namespace QuestPDF.Drawing
 
             void ThrowLayoutException()
             {
-                throw new DocumentLayoutException("Composed layout generates infinite document.")
+                var message = $"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.";
+                
+                throw new DocumentLayoutException(message)
                 {
                     ElementTrace = debuggingState?.BuildTrace() ?? "Debug trace is available only in the DEBUG mode."
                 };
-                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.");
             }
         }