HyperlinkExamples.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using QuestPDF.Fluent;
  2. using QuestPDF.Helpers;
  3. using QuestPDF.Infrastructure;
  4. namespace QuestPDF.DocumentationExamples;
  5. public class HyperlinkExamples
  6. {
  7. [Test]
  8. public void ElementExample()
  9. {
  10. Document
  11. .Create(document =>
  12. {
  13. document.Page(page =>
  14. {
  15. page.ContinuousSize(400);
  16. page.DefaultTextStyle(x => x.FontSize(20));
  17. page.Margin(25);
  18. page.Content()
  19. .Column(column =>
  20. {
  21. column.Spacing(25);
  22. column.Item()
  23. .Text("Clicking the NuGet logo will redirect you to the NuGet website.");
  24. column.Item()
  25. .Width(150)
  26. .Hyperlink("https://www.nuget.org/")
  27. .Svg("Resources/nuget-logo.svg");
  28. });
  29. });
  30. })
  31. .GeneratePdf("hyperlink-element.pdf");
  32. }
  33. [Test]
  34. public void InsideTextExample()
  35. {
  36. Document
  37. .Create(document =>
  38. {
  39. document.Page(page =>
  40. {
  41. page.ContinuousSize(300);
  42. page.DefaultTextStyle(x => x.FontSize(20));
  43. page.Margin(25);
  44. page.Content()
  45. .Text(text =>
  46. {
  47. text.Span("Click ");
  48. text.Hyperlink("here", "https://www.nuget.org/").Underline().FontColor(Colors.Blue.Darken2);
  49. text.Span(" to visit the official NuGet website.");
  50. });
  51. });
  52. })
  53. .GeneratePdf("hyperlink-text.pdf");
  54. }
  55. }