ElementExamples.cs 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930
  1. using System.Linq;
  2. using NUnit.Framework;
  3. using QuestPDF.Examples.Engine;
  4. using QuestPDF.Fluent;
  5. using QuestPDF.Helpers;
  6. using QuestPDF.Infrastructure;
  7. using SkiaSharp;
  8. namespace QuestPDF.Examples
  9. {
  10. [TestFixture]
  11. public class ElementExamples
  12. {
  13. [Test]
  14. public void Placeholder()
  15. {
  16. RenderingTest
  17. .Create()
  18. .PageSize(200, 150)
  19. .Render(container =>
  20. {
  21. container
  22. .Background("#FFF")
  23. .Padding(25)
  24. .Placeholder();
  25. });
  26. }
  27. [Test]
  28. public void Decoration()
  29. {
  30. RenderingTest
  31. .Create()
  32. .PageSize(300, 300)
  33. .Render(container =>
  34. {
  35. container
  36. .Background("#FFF")
  37. .Padding(25)
  38. .Decoration(decoration =>
  39. {
  40. decoration
  41. .Before()
  42. .Background(Colors.Grey.Medium)
  43. .Padding(10)
  44. .Text("Notes")
  45. .FontSize(16)
  46. .FontColor("#FFF");
  47. decoration
  48. .Content()
  49. .Background(Colors.Grey.Lighten3)
  50. .Padding(10)
  51. .ExtendVertical()
  52. .Text(Helpers.Placeholders.LoremIpsum());
  53. });
  54. });
  55. }
  56. [Test]
  57. public void Row()
  58. {
  59. RenderingTest
  60. .Create()
  61. .PageSize(740, 200)
  62. .Render(container =>
  63. {
  64. container
  65. .Background("#FFF")
  66. .Padding(20)
  67. .Column(column =>
  68. {
  69. column.Item()
  70. .PaddingBottom(10)
  71. .AlignCenter()
  72. .Text("This Row element is 700pt wide");
  73. column.Item().Row(row =>
  74. {
  75. row.ConstantItem(100)
  76. .Background(Colors.Grey.Lighten1)
  77. .Padding(10)
  78. .ExtendVertical()
  79. .Text("This column is 100 pt wide");
  80. row.RelativeItem()
  81. .Background(Colors.Grey.Lighten2)
  82. .Padding(10)
  83. .Text("This column takes 1/3 of the available space (200pt)");
  84. row.RelativeItem(2)
  85. .Background(Colors.Grey.Lighten3)
  86. .Padding(10)
  87. .Text("This column takes 2/3 of the available space (400pt)");
  88. });
  89. });
  90. });
  91. }
  92. [Test]
  93. public void RowSpacing()
  94. {
  95. RenderingTest
  96. .Create()
  97. .PageSize(740, 200)
  98. .Render(container =>
  99. {
  100. container
  101. .Background("#FFF")
  102. .Padding(20)
  103. .Row(row =>
  104. {
  105. row.Spacing(20);
  106. row.RelativeItem(2).Border(1).Background(Colors.Grey.Lighten1);
  107. row.RelativeItem(3).Border(1).Background(Colors.Grey.Lighten2);
  108. row.RelativeItem(4).Border(1).Background(Colors.Grey.Lighten3);
  109. });
  110. });
  111. }
  112. [Test]
  113. public void column()
  114. {
  115. RenderingTest
  116. .Create()
  117. .PageSize(500, 360)
  118. .Render(container =>
  119. {
  120. container
  121. .Background("#FFF")
  122. .Padding(15)
  123. .Column(column =>
  124. {
  125. column.Spacing(15);
  126. column.Item().Background(Colors.Grey.Medium).Height(50);
  127. column.Item().Background(Colors.Grey.Lighten1).Height(100);
  128. column.Item().Background(Colors.Grey.Lighten2).Height(150);
  129. });
  130. });
  131. }
  132. [Test]
  133. public void Debug()
  134. {
  135. RenderingTest
  136. .Create()
  137. .PageSize(210, 210)
  138. .Render(container =>
  139. {
  140. container
  141. .Padding(25)
  142. .DebugArea("Grid example", Colors.Blue.Medium)
  143. .Grid(grid =>
  144. {
  145. grid.Columns(3);
  146. grid.Spacing(5);
  147. foreach (var _ in Enumerable.Range(0, 8))
  148. grid.Item().Height(50).Placeholder();
  149. });
  150. });
  151. }
  152. [Test]
  153. public void ElementEnd()
  154. {
  155. RenderingTest
  156. .Create()
  157. .PageSize(300, 200)
  158. .Render(container =>
  159. {
  160. var text = "";
  161. container
  162. .Padding(10)
  163. .Element(x =>
  164. {
  165. if (string.IsNullOrWhiteSpace(text))
  166. x.Height(10).Width(50).Background("#DDD");
  167. else
  168. x.Text(text);
  169. });
  170. });
  171. }
  172. [Test]
  173. public void GridExample()
  174. {
  175. RenderingTest
  176. .Create()
  177. .PageSize(400, 230)
  178. .Render(container =>
  179. {
  180. var textStyle = TextStyle.Default.Size(14);
  181. container
  182. .Padding(15)
  183. .AlignRight()
  184. .Grid(grid =>
  185. {
  186. grid.VerticalSpacing(10);
  187. grid.HorizontalSpacing(10);
  188. grid.AlignCenter();
  189. grid.Columns(10); // 12 by default
  190. grid.Item(6).Background(Colors.Blue.Lighten1).Height(50);
  191. grid.Item(4).Background(Colors.Blue.Lighten3).Height(50);
  192. grid.Item(2).Background(Colors.Teal.Lighten1).Height(70);
  193. grid.Item(3).Background(Colors.Teal.Lighten2).Height(70);
  194. grid.Item(5).Background(Colors.Teal.Lighten3).Height(70);
  195. grid.Item(2).Background(Colors.Green.Lighten1).Height(50);
  196. grid.Item(2).Background(Colors.Green.Lighten2).Height(50);
  197. grid.Item(2).Background(Colors.Green.Lighten3).Height(50);
  198. });
  199. });
  200. }
  201. [Test]
  202. public void Canvas()
  203. {
  204. RenderingTest
  205. .Create()
  206. .PageSize(300, 200)
  207. .Render(container =>
  208. {
  209. container
  210. .Background("#FFF")
  211. .Padding(25)
  212. .Canvas((canvas, size) =>
  213. {
  214. using var paint = new SKPaint
  215. {
  216. Color = SKColors.Red,
  217. StrokeWidth = 10,
  218. IsStroke = true
  219. };
  220. // move origin to the center of the available space
  221. canvas.Translate(size.Width / 2, size.Height / 2);
  222. // draw a circle
  223. canvas.DrawCircle(0, 0, 50, paint);
  224. });
  225. });
  226. }
  227. [Test]
  228. public void LayersExample()
  229. {
  230. RenderingTest
  231. .Create()
  232. .PageSize(400, 250)
  233. .Render(container =>
  234. {
  235. container
  236. .Padding(25)
  237. .Layers(layers =>
  238. {
  239. // layer below main content
  240. layers
  241. .Layer()
  242. .Height(100)
  243. .Width(100)
  244. .Background(Colors.Grey.Lighten3);
  245. layers
  246. .PrimaryLayer()
  247. .Padding(25)
  248. .Column(column =>
  249. {
  250. column.Spacing(5);
  251. foreach (var _ in Enumerable.Range(0, 7))
  252. column.Item().Text(Placeholders.Sentence());
  253. });
  254. // layer above the main content
  255. layers
  256. .Layer()
  257. .AlignCenter()
  258. .AlignMiddle()
  259. .Text("Watermark")
  260. .FontSize(48)
  261. .Bold()
  262. .FontColor(Colors.Green.Lighten3);
  263. layers
  264. .Layer()
  265. .AlignBottom()
  266. .Text(text => text.CurrentPageNumber().FontSize(16).FontColor(Colors.Green.Medium));
  267. });
  268. });
  269. }
  270. // [Test]
  271. // public void EnsureSpace()
  272. // {
  273. // RenderingTest
  274. // .Create()
  275. // .PageSize(300, 400)
  276. // .Render(container =>
  277. // {
  278. // container
  279. // .Padding(50)
  280. // .Page(page =>
  281. // {
  282. // page.Header().PageNumber("Page {pdf:currentPage}");
  283. //
  284. // page.Content().Height(300).column(content =>
  285. // {
  286. // content.Item().Height(200).Background(Colors.Grey.Lighten2);
  287. //
  288. // content.Item().EnsureSpace(100).column(column =>
  289. // {
  290. // column.Spacing(10);
  291. //
  292. // foreach (var _ in Enumerable.Range(0, 4))
  293. // column.Item().Height(50).Background(Colors.Green.Lighten1);
  294. // });
  295. // });
  296. // });
  297. // });
  298. // }
  299. [Test]
  300. public void RandomColorMatrix()
  301. {
  302. RenderingTest
  303. .Create()
  304. .PageSize(300, 300)
  305. .Render(container =>
  306. {
  307. container
  308. .Padding(25)
  309. .Grid(grid =>
  310. {
  311. grid.Columns(5);
  312. Enumerable
  313. .Range(0, 25)
  314. .Select(x => Placeholders.BackgroundColor())
  315. .ToList()
  316. .ForEach(x => grid.Item().Height(50).Background(x));
  317. });
  318. });
  319. }
  320. [Test]
  321. public void DefinedColors()
  322. {
  323. var colors = new[]
  324. {
  325. Colors.Green.Darken4,
  326. Colors.Green.Darken3,
  327. Colors.Green.Darken2,
  328. Colors.Green.Darken1,
  329. Colors.Green.Medium,
  330. Colors.Green.Lighten1,
  331. Colors.Green.Lighten2,
  332. Colors.Green.Lighten3,
  333. Colors.Green.Lighten4,
  334. Colors.Green.Lighten5,
  335. Colors.Green.Accent1,
  336. Colors.Green.Accent2,
  337. Colors.Green.Accent3,
  338. Colors.Green.Accent4,
  339. };
  340. RenderingTest
  341. .Create()
  342. .PageSize(450, 150)
  343. .Render(container =>
  344. {
  345. container
  346. .Padding(25)
  347. .Height(100)
  348. .Row(row =>
  349. {
  350. foreach (var color in colors)
  351. row.RelativeItem().Background(color);
  352. });
  353. });
  354. }
  355. [Test]
  356. public void DefinedFonts()
  357. {
  358. var fonts = new[]
  359. {
  360. Fonts.Calibri,
  361. Fonts.Candara,
  362. Fonts.Arial,
  363. Fonts.TimesNewRoman,
  364. Fonts.Consolas,
  365. Fonts.Tahoma,
  366. Fonts.Impact,
  367. Fonts.Trebuchet,
  368. Fonts.ComicSans
  369. };
  370. RenderingTest
  371. .Create()
  372. .PageSize(500, 175)
  373. .Render(container =>
  374. {
  375. container
  376. .Padding(25)
  377. .Grid(grid =>
  378. {
  379. grid.Columns(3);
  380. foreach (var font in fonts)
  381. {
  382. grid.Item()
  383. .Border(1)
  384. .BorderColor(Colors.Grey.Medium)
  385. .Padding(10)
  386. .Text(font)
  387. .FontFamily(font)
  388. .FontSize(16);
  389. }
  390. });
  391. });
  392. }
  393. [Test]
  394. public void Layers()
  395. {
  396. RenderingTest
  397. .Create()
  398. .PageSize(300, 300)
  399. .Render(container =>
  400. {
  401. container
  402. .Background("#FFF")
  403. .Padding(25)
  404. .Layers(layers =>
  405. {
  406. layers.Layer().Text("Something else");
  407. layers.PrimaryLayer().Column(column =>
  408. {
  409. column.Item().PaddingTop(20).Text("Text 1");
  410. column.Item().PaddingTop(40).Text("Text 2");
  411. });
  412. layers.Layer().Canvas((canvas, size) =>
  413. {
  414. using var paint = new SKPaint
  415. {
  416. Color = SKColors.Red,
  417. StrokeWidth = 5
  418. };
  419. canvas.Translate(size.Width / 2, size.Height / 2);
  420. canvas.DrawCircle(0, 0, 50, paint);
  421. });
  422. layers.Layer().Background("#8F00").Extend();
  423. layers.Layer().PaddingTop(40).Text("It works!").FontSize(24);
  424. });
  425. });
  426. }
  427. [Test]
  428. public void Box()
  429. {
  430. RenderingTest
  431. .Create()
  432. .PageSize(300, 150)
  433. .Render(container =>
  434. {
  435. container
  436. .Background("#FFF")
  437. .Padding(15)
  438. .Border(4)
  439. .BorderColor(Colors.Blue.Medium)
  440. //.MinimalBox()
  441. .Background(Colors.Grey.Lighten2)
  442. .Padding(15)
  443. .Text("Test of the \n box element").FontSize(20);
  444. });
  445. }
  446. [Test]
  447. public void Scale()
  448. {
  449. RenderingTest
  450. .Create()
  451. .PageSize(300, 175)
  452. .Render(container =>
  453. {
  454. container
  455. .Background(Colors.White)
  456. .Padding(10)
  457. .Decoration(decoration =>
  458. {
  459. var headerFontStyle = TextStyle
  460. .Default
  461. .Size(20)
  462. .Color(Colors.Blue.Darken2)
  463. .SemiBold();
  464. decoration
  465. .Before()
  466. .PaddingBottom(10)
  467. .Text("Example: scale component")
  468. .Style(headerFontStyle);
  469. decoration
  470. .Content()
  471. .Column(column =>
  472. {
  473. var scales = new[] { 0.8f, 0.9f, 1.1f, 1.2f };
  474. foreach (var scale in scales)
  475. {
  476. var fontColor = scale <= 1f
  477. ? Colors.Red.Lighten4
  478. : Colors.Green.Lighten4;
  479. var fontStyle = TextStyle.Default.Size(16);
  480. column
  481. .Item()
  482. .Border(1)
  483. .Background(fontColor)
  484. .Scale(scale)
  485. .Padding(5)
  486. .Text($"Content with {scale} scale.")
  487. .Style(fontStyle);
  488. }
  489. });
  490. });
  491. });
  492. }
  493. [Test]
  494. public void Translate()
  495. {
  496. RenderingTest
  497. .Create()
  498. .PageSize(300, 200)
  499. .Render(container =>
  500. {
  501. container
  502. .Background("#FFF")
  503. .MinimalBox()
  504. .Padding(25)
  505. .Background(Colors.Green.Lighten3)
  506. .TranslateX(15)
  507. .TranslateY(15)
  508. .Border(2)
  509. .BorderColor(Colors.Green.Darken1)
  510. .Padding(50)
  511. .Text("Moved text")
  512. .FontSize(25);
  513. });
  514. }
  515. [Test]
  516. public void ConstrainedRotate()
  517. {
  518. RenderingTest
  519. .Create()
  520. .PageSize(650, 450)
  521. .Render(container =>
  522. {
  523. container
  524. .Padding(20)
  525. .Grid(grid =>
  526. {
  527. grid.Columns(2);
  528. grid.Spacing(10);
  529. foreach (var turns in Enumerable.Range(0, 4))
  530. {
  531. grid.Item()
  532. .Width(300)
  533. .Height(200)
  534. .Background(Colors.Grey.Lighten2)
  535. .Padding(10)
  536. .Element(element =>
  537. {
  538. foreach (var x in Enumerable.Range(0, turns))
  539. element = element.RotateRight();
  540. return element;
  541. })
  542. .MinimalBox()
  543. .Background(Colors.White)
  544. .Padding(10)
  545. .Text($"Rotated {turns * 90}°")
  546. .FontSize(16);
  547. }
  548. });
  549. });
  550. }
  551. [Test]
  552. public void FreeRotate()
  553. {
  554. RenderingTest
  555. .Create()
  556. .PageSize(300, 300)
  557. .Render(container =>
  558. {
  559. container
  560. .Padding(25)
  561. .Background(Colors.Grey.Lighten2)
  562. .AlignCenter()
  563. .AlignMiddle()
  564. .Background(Colors.White)
  565. .Rotate(30)
  566. .Width(100)
  567. .Height(100)
  568. .Background(Colors.Blue.Medium);
  569. });
  570. }
  571. [Test]
  572. public void FreeRotateCenter()
  573. {
  574. RenderingTest
  575. .Create()
  576. .PageSize(300, 300)
  577. .Render(container =>
  578. {
  579. container
  580. .Padding(25)
  581. .Background(Colors.Grey.Lighten2)
  582. .AlignCenter()
  583. .AlignMiddle()
  584. .Background(Colors.White)
  585. .TranslateX(50)
  586. .TranslateY(50)
  587. .Rotate(30)
  588. .TranslateX(-50)
  589. .TranslateY(-50)
  590. .Width(100)
  591. .Height(100)
  592. .Background(Colors.Blue.Medium);
  593. });
  594. }
  595. [Test]
  596. public void Flip()
  597. {
  598. RenderingTest
  599. .Create()
  600. .PageSize(350, 350)
  601. .Render(container =>
  602. {
  603. container
  604. .Padding(20)
  605. .Grid(grid =>
  606. {
  607. grid.Columns(2);
  608. grid.Spacing(10);
  609. foreach (var turns in Enumerable.Range(0, 4))
  610. {
  611. grid.Item()
  612. .Width(150)
  613. .Height(150)
  614. .Background(Colors.Grey.Lighten3)
  615. .Padding(10)
  616. .Element(element =>
  617. {
  618. if (turns == 1 || turns == 2)
  619. element = element.FlipHorizontal();
  620. if (turns == 2 || turns == 3)
  621. element = element.FlipVertical();
  622. return element;
  623. })
  624. .MinimalBox()
  625. .Background(Colors.White)
  626. .Padding(10)
  627. .Text($"Flipped {turns}")
  628. .FontSize(16);
  629. }
  630. });
  631. });
  632. }
  633. [Test]
  634. public void RotateInTable()
  635. {
  636. RenderingTest
  637. .Create()
  638. .PageSize(200, 200)
  639. .Render(container =>
  640. {
  641. container
  642. .Padding(10)
  643. .Border(2)
  644. .Row(row =>
  645. {
  646. row.ConstantItem(25)
  647. .Border(1)
  648. .RotateLeft()
  649. .AlignCenter()
  650. .AlignMiddle()
  651. .Text("Sample text");
  652. row.RelativeItem().Border(1).Padding(5).Text(Placeholders.Paragraph());
  653. });
  654. });
  655. }
  656. [Test]
  657. public void Unconstrained()
  658. {
  659. RenderingTest
  660. .Create()
  661. .PageSize(400, 350)
  662. .Render(container =>
  663. {
  664. container
  665. .Padding(25)
  666. .PaddingLeft(50)
  667. .Column(column =>
  668. {
  669. column.Item().Width(300).Height(150).Background(Colors.Blue.Lighten4);
  670. column
  671. .Item()
  672. // creates an infinite space for its child
  673. .Unconstrained()
  674. // moves the child up and left
  675. .TranslateX(-50)
  676. .TranslateY(-50)
  677. // limits the space for the child
  678. .Width(100)
  679. .Height(100)
  680. .Background(Colors.Blue.Darken1);
  681. column.Item().Width(300).Height(150).Background(Colors.Blue.Lighten3);
  682. });
  683. });
  684. }
  685. [Test]
  686. public void ComplexLayout()
  687. {
  688. RenderingTest
  689. .Create()
  690. .PageSize(500, 225)
  691. .Render(container =>
  692. {
  693. container
  694. .Padding(25)
  695. .Column(column =>
  696. {
  697. column.Item().Row(row =>
  698. {
  699. row.RelativeItem().LabelCell("Label 1");
  700. row.RelativeItem(3).Grid(grid =>
  701. {
  702. grid.Columns(3);
  703. grid.Item(2).LabelCell("Label 2");
  704. grid.Item().LabelCell("Label 3");
  705. grid.Item(2).ValueCell().Text("Value 2");
  706. grid.Item().ValueCell().Text("Value 3");
  707. });
  708. });
  709. column.Item().Row(row =>
  710. {
  711. row.RelativeItem().ValueCell().Text("Value 1");
  712. row.RelativeItem(3).Grid(grid =>
  713. {
  714. grid.Columns(3);
  715. grid.Item().LabelCell("Label 4");
  716. grid.Item(2).LabelCell("Label 5");
  717. grid.Item().ValueCell().Text("Value 4");
  718. grid.Item(2).ValueCell().Text("Value 5");
  719. });
  720. });
  721. column.Item().Row(row =>
  722. {
  723. row.RelativeItem().LabelCell("Label 6");
  724. row.RelativeItem().ValueCell().Text("Value 6");
  725. });
  726. });
  727. });
  728. }
  729. [Test]
  730. public void DomainSpecificLanguage()
  731. {
  732. RenderingTest
  733. .Create()
  734. .PageSize(600, 310)
  735. .Render(container =>
  736. {
  737. container
  738. .Padding(25)
  739. .Grid(grid =>
  740. {
  741. grid.Columns(10);
  742. for(var i=1; i<=4; i++)
  743. {
  744. grid.Item(2).LabelCell(Placeholders.Label());
  745. grid.Item(3).ValueCell().Image(Placeholders.Image(200, 150));
  746. }
  747. });
  748. });
  749. }
  750. [Test]
  751. public void DividingPageIntoPartsOfEqualSize()
  752. {
  753. RenderingTest
  754. .Create()
  755. .ProduceImages()
  756. .ShowResults()
  757. .PageSize(PageSizes.A4)
  758. .Render(container =>
  759. {
  760. var labelsVertically = 9;
  761. var labelsHorizontally = 3;
  762. container
  763. .Padding(25)
  764. .RotateRight()
  765. .Row(verticalRow =>
  766. {
  767. foreach (var y in Enumerable.Range(1, labelsVertically))
  768. {
  769. verticalRow.RelativeItem().RotateLeft().Row(horizontalRow =>
  770. {
  771. foreach (var x in Enumerable.Range(1, labelsHorizontally))
  772. {
  773. horizontalRow.RelativeItem()
  774. .Border(1)
  775. .Background(Placeholders.BackgroundColor())
  776. .AlignCenter()
  777. .AlignMiddle()
  778. .Text($"{x} x {y}")
  779. .FontSize(20);
  780. }
  781. });
  782. }
  783. });
  784. });
  785. }
  786. [Test]
  787. public void DividingPageIntoPartsOfExpectedSize()
  788. {
  789. RenderingTest
  790. .Create()
  791. .ProduceImages()
  792. .ShowResults()
  793. .PageSize(PageSizes.A4)
  794. .Render(container =>
  795. {
  796. var labelsVertically = 9;
  797. var labelsHorizontally = 3;
  798. var labelWidth = 150;
  799. var labelHeight = 100;
  800. container
  801. .Padding(25)
  802. .Table(table =>
  803. {
  804. table.ColumnsDefinition(columns =>
  805. {
  806. foreach (var i in Enumerable.Range(0, labelsHorizontally))
  807. columns.ConstantColumn(labelWidth);
  808. });
  809. foreach (var y in Enumerable.Range(1, labelsVertically))
  810. {
  811. foreach (var x in Enumerable.Range(1, labelsHorizontally))
  812. {
  813. table.Cell()
  814. .Width(labelWidth)
  815. .Height(labelHeight)
  816. .Border(1)
  817. .Background(Placeholders.BackgroundColor())
  818. .AlignCenter()
  819. .AlignMiddle()
  820. .Text($"{x} x {y}")
  821. .FontSize(20);
  822. }
  823. }
  824. });
  825. });
  826. }
  827. }
  828. }