ソースを参照

Simplified generated document structure

MarcinZiabek 2 年 前
コミット
7d55bc35fa
1 ファイル変更26 行追加14 行削除
  1. 26 14
      Source/QuestPDF/Drawing/DocumentContainer.cs

+ 26 - 14
Source/QuestPDF/Drawing/DocumentContainer.cs

@@ -14,22 +14,34 @@ namespace QuestPDF.Drawing
         internal Container Compose()
         internal Container Compose()
         {
         {
             var container = new Container();
             var container = new Container();
-            
-            container
-                .Column(column =>
+            ComposeContainer(container);
+            return container;
+
+            void ComposeContainer(IContainer container)
+            {
+                if (Pages.Count == 0)
+                    return;
+                
+                if (Pages.Count == 1)
                 {
                 {
-                    Pages
-                        .SelectMany(x => new List<Action>()
-                        {
-                            () => column.Item().PageBreak(),
-                            () => column.Item().Component(x)
-                        })
-                        .Skip(1)
-                        .ToList()
-                        .ForEach(x => x());
-                });
+                    container.Component(Pages.First());
+                    return;
+                }
 
 
-            return container;
+                container
+                    .Column(column =>
+                    {
+                        Pages
+                            .SelectMany(x => new List<Action>()
+                            {
+                                () => column.Item().PageBreak(),
+                                () => column.Item().Component(x)
+                            })
+                            .Skip(1)
+                            .ToList()
+                            .ForEach(x => x());
+                    });
+            }
         }
         }
     }
     }
 }
 }