Settings.cs 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System;
  2. using System.Collections.Generic;
  3. using QuestPDF.Infrastructure;
  4. using QuestPDF.Skia;
  5. namespace QuestPDF
  6. {
  7. public static class Settings
  8. {
  9. /// <summary>
  10. /// <para>Please kindly select license type that applies to your usage of the QuestPDF library.</para>
  11. /// <para>For more details, please check the <a href="https://www.questpdf.com/license">QuestPDF License and Pricing webpage</a></para>
  12. /// </summary>
  13. public static LicenseType? License { get; set; }
  14. [Obsolete("This setting is ignored since the 2023.10 version. The new infinite layout detection algorithm works automatically. You can safely remove this setting from your codebase.")]
  15. public static int DocumentLayoutExceptionThreshold { get; set; } = 250;
  16. /// <summary>
  17. /// This flag generates additional document elements to cache layout calculation results.
  18. /// In the vast majority of cases, this significantly improves performance, while slightly increasing memory consumption.
  19. /// </summary>
  20. /// <remarks>Enabled by default.</remarks>
  21. public static bool EnableCaching { get; set; } = true;
  22. /// <summary>
  23. /// This flag generates additional document elements to improve layout debugging experience.
  24. /// When the provided content contains size constraints impossible to meet, the library generates an enhanced exception message with additional location and layout measurement details.
  25. /// </summary>
  26. /// <remarks>By default, this flag is enabled only when the debugger IS attached.</remarks>
  27. public static bool EnableDebugging { get; set; } = System.Diagnostics.Debugger.IsAttached;
  28. /// <summary>
  29. /// This flag enables checking the font glyph availability.
  30. /// If your text contains glyphs that are not present in the specified font,
  31. /// 1) when this flag is enabled: the DocumentDrawingException is thrown. OR
  32. /// 2) when this flag is disabled: placeholder characters are visible in the produced PDF file.
  33. /// Enabling this flag may slightly decrease document generation performance.
  34. /// However, it provides hints that used fonts are not sufficient to produce correct results.
  35. /// </summary>
  36. /// <remarks>By default, this flag is enabled only when the debugger IS attached.</remarks>
  37. public static bool CheckIfAllTextGlyphsAreAvailable { get; set; } = System.Diagnostics.Debugger.IsAttached;
  38. /// <summary>
  39. /// Decides whether the application should use the fonts available in the environment.
  40. /// </summary>
  41. /// <remarks>
  42. /// <para>When set to <c>true</c>, the application will use the fonts installed on the system where it is running. This is the default behavior.</para>
  43. /// <para>When set to <c>false</c>, the application will only use the fonts that have been registered using the <c>FontManager</c> class in the QuestPDF library.</para>
  44. /// <para>This property is useful when you want to control the fonts used by your application, especially in cases where the environment might not have the necessary fonts installed.</para>
  45. /// </remarks>
  46. public static bool UseEnvironmentFonts { get; set; } = true;
  47. /// <summary>
  48. /// Specifies the collection of paths where the library will automatically search for font files to register.
  49. /// </summary>
  50. /// <remarks>
  51. /// <para>By default, this collection contains the application files path.</para>
  52. /// <para>You can add additional paths to this collection to include more directories for automatic font registration.</para>
  53. /// </remarks>
  54. public static ICollection<string> FontDiscoveryPaths { get; } = new List<string>()
  55. {
  56. Helpers.Helpers.ApplicationFilesPath
  57. };
  58. static Settings()
  59. {
  60. SkNativeDependencyCompatibilityChecker.Test();
  61. }
  62. }
  63. }