| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- using QuestPDF.Fluent;
- using QuestPDF.Helpers;
- using QuestPDF.Infrastructure;
- namespace QuestPDF.DocumentationExamples;
- public class LazyExamples
- {
- class SimpleComponent : IComponent
- {
- public required int Start { get; init; }
- public required int End { get; init; }
-
- public void Compose(IContainer container)
- {
- container.Decoration(decoration =>
- {
- decoration.Before()
- .Text($"Numbers from {Start} to {End}")
- .FontSize(20).Bold().FontColor(Colors.Blue.Darken2);
-
- decoration.Content().Column(column =>
- {
- foreach (var i in Enumerable.Range(Start, End - Start + 1))
- column.Item().Text($"Number {i}").FontSize(10);
- });
- });
- }
- }
- [Test]
- [Ignore("This test is for manual testing only.")]
- public void Disabled()
- {
- Document
- .Create(document =>
- {
- document.Page(page =>
- {
- page.Margin(10);
- page.Content().Column(column =>
- {
- const int sectionSize = 1000;
-
- foreach (var i in Enumerable.Range(0, 1000))
- {
- column.Item().Component(new SimpleComponent
- {
- Start = i * sectionSize,
- End = i * sectionSize + sectionSize - 1
- });
- }
- });
- });
- })
- .GeneratePdf("lazy-disabled.pdf");
- }
- [Test]
- [Ignore("This test is for manual testing only.")]
- public void Enabled()
- {
- Document
- .Create(document =>
- {
- document.Page(page =>
- {
- page.Margin(10);
- page.Content().Column(column =>
- {
- const int sectionSize = 1000;
- foreach (var i in Enumerable.Range(0, 1000))
- {
- var start = i * sectionSize;
- var end = start + sectionSize - 1;
- column.Item().Lazy(c =>
- {
- c.Component(new SimpleComponent
- {
- Start = start,
- End = end
- });
- });
- }
- });
- });
- })
- .GeneratePdf("lazy-enabled.pdf");
- }
-
- [Test]
- [Ignore("This test is for manual testing only.")]
- public void EnabledWithCache()
- {
- Document
- .Create(document =>
- {
- document.Page(page =>
- {
- page.Margin(10);
- page.Content().Column(column =>
- {
- const int sectionSize = 1000;
- foreach (var i in Enumerable.Range(0, 1000))
- {
- var start = i * sectionSize;
- var end = start + sectionSize - 1;
- column.Item().LazyWithCache(c =>
- {
- c.Component(new SimpleComponent
- {
- Start = start,
- End = end
- });
- });
- }
- });
- });
- })
- .GeneratePdf("lazy-enabled-with-cache.pdf");
- }
- }
|