ElementExamples.cs 33 KB

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