AspectRatioExamples.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. using QuestPDF.Fluent;
  2. using QuestPDF.Helpers;
  3. using QuestPDF.Infrastructure;
  4. namespace QuestPDF.DocumentationExamples;
  5. public class AspectRatioExamples
  6. {
  7. [Test]
  8. public void Example()
  9. {
  10. Document
  11. .Create(document =>
  12. {
  13. document.Page(page =>
  14. {
  15. page.MinSize(new PageSize(0, 0));
  16. page.MaxSize(new PageSize(1000, 1000));
  17. page.DefaultTextStyle(x => x.FontSize(20));
  18. page.Content()
  19. .Width(300)
  20. .Height(300)
  21. .AspectRatio(3f/4f, AspectRatioOption.FitArea)
  22. .Background(Colors.Grey.Lighten2)
  23. .AlignCenter()
  24. .AlignMiddle()
  25. .Text("3:4 Content Area");
  26. });
  27. })
  28. .GenerateImages(x => "aspect-ratio.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.VeryHigh, RasterDpi = 144 });
  29. }
  30. }