SkipOnceExamples.cs 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using QuestPDF.Fluent;
  2. using QuestPDF.Helpers;
  3. using QuestPDF.Infrastructure;
  4. namespace QuestPDF.DocumentationExamples;
  5. public class SkipOnceExamples
  6. {
  7. [Test]
  8. public void Example()
  9. {
  10. Document
  11. .Create(document =>
  12. {
  13. document.Page(page =>
  14. {
  15. page.Size(500, 500);
  16. page.DefaultTextStyle(x => x.FontSize(20));
  17. page.Margin(25);
  18. page.Content()
  19. .Column(column =>
  20. {
  21. var terms = new[]
  22. {
  23. ("Repository", "A centralized storage location for source code and related files, typically managed using version control systems like Git. Repositories allow multiple developers to collaborate on projects, track changes, and maintain version history."),
  24. ("Version Control", "A system that tracks changes to code over time, enabling developers to collaborate efficiently, revert to previous versions, and maintain a structured development workflow. Popular version control tools include Git, Mercurial, and Subversion."),
  25. ("Abstraction", "A programming concept that hides complex implementation details and exposes only the necessary parts. Abstraction helps simplify code and allows developers to focus on high-level design rather than low-level implementation details."),
  26. ("Namespace", "A container that groups related identifiers, such as variables, functions, and classes, to prevent naming conflicts in a program. Namespaces are commonly used in large projects to organize code efficiently."),
  27. };
  28. column.Spacing(15);
  29. foreach (var term in terms)
  30. {
  31. column.Item().Decoration(decoration =>
  32. {
  33. decoration.Before()
  34. .DefaultTextStyle(x => x.FontSize(24).Bold().FontColor(Colors.Blue.Darken2))
  35. .Column(innerColumn =>
  36. {
  37. innerColumn.Item().ShowOnce().Text(term.Item1);
  38. innerColumn.Item().SkipOnce().Text(text =>
  39. {
  40. text.Span(term.Item1);
  41. text.Span(" (continued)").Light().Italic();
  42. });
  43. });
  44. decoration.Content().Text(term.Item2);
  45. });
  46. }
  47. });
  48. });
  49. })
  50. .GenerateImages(x => $"skip-once-{x}.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.Best, RasterDpi = 144 });
  51. }
  52. }