diff --git a/.github/workflows/update-examples.yml b/.github/workflows/update-examples.yml new file mode 100644 index 0000000..8266d80 --- /dev/null +++ b/.github/workflows/update-examples.yml @@ -0,0 +1,63 @@ +name: Update examples + +# Exports the code examples and images from QuestPDF.DocumentationExamples (QuestPDF repository) +# into docs/snippets and docs/public, and commits the changes to the branch it runs on. + +on: + pull_request: + workflow_dispatch: + inputs: + questpdf-ref: + description: QuestPDF branch or tag to take the examples from + required: true + default: main + +permissions: {} + +env: + QUESTPDF_REF: ${{ inputs.questpdf-ref || 'docs-examples/snippet-export' }} + +jobs: + update: + name: Update examples + runs-on: ubuntu-latest + timeout-minutes: 15 + if: github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository + permissions: + contents: write + + steps: + - name: Checkout documentation + uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref || github.ref_name }} + + - name: Checkout QuestPDF + uses: actions/checkout@v4 + with: + repository: QuestPDF/QuestPDF + ref: ${{ env.QUESTPDF_REF }} + path: .questpdf + sparse-checkout: src/dotnet/library + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 10.0.x + + - name: Export examples + run: dotnet run .questpdf/src/dotnet/library/tools/export-documentation-snippets.cs -- docs + + - name: Commit changes + run: | + git add docs/snippets docs/public + + if git diff --cached --quiet; then + echo "The examples are up to date." + exit 0 + fi + + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git commit -m "Update examples from QuestPDF $QUESTPDF_REF ($(git -C .questpdf rev-parse --short HEAD))" + git push diff --git a/docs/.vitepress/theme/VitepressAdjustments.css b/docs/.vitepress/theme/VitepressAdjustments.css index b63979f..c6cb316 100644 --- a/docs/.vitepress/theme/VitepressAdjustments.css +++ b/docs/.vitepress/theme/VitepressAdjustments.css @@ -118,15 +118,18 @@ body { } } -html:not(.dark) .VPDoc img[alt=example] { +html:not(.dark) .VPDoc img[alt=example], +html:not(.dark) .VPDoc img.example { border: 1px solid #888; } -html.dark .VPDoc img[alt=example] { +html.dark .VPDoc img[alt=example], +html.dark .VPDoc img.example { opacity: 0.75; } -.VPDoc img[alt=example] { +.VPDoc img[alt=example], +.VPDoc img.example { box-shadow: 0 13px 27px -5px rgb(50 50 93 / 15%), 0 8px 16px -8px rgb(0 0 0 / 10%), 0 -6px 16px -6px rgb(0 0 0 / 5%); margin-bottom: 16px; border-radius: 8px; diff --git a/docs/api-reference/background.md b/docs/api-reference/background.md index 7a877da..b22f129 100644 --- a/docs/api-reference/background.md +++ b/docs/api-reference/background.md @@ -18,41 +18,9 @@ Sets a solid background color behind its content. .Background(Colors.Green.Lighten2) ``` -```csharp{30} -using QuestPDF.Helpers; - -var colors = new[] -{ - Colors.LightBlue.Darken4, - Colors.LightBlue.Darken3, - Colors.LightBlue.Darken2, - Colors.LightBlue.Darken1, - - Colors.LightBlue.Medium, - - Colors.LightBlue.Lighten1, - Colors.LightBlue.Lighten2, - Colors.LightBlue.Lighten3, - Colors.LightBlue.Lighten4, - Colors.LightBlue.Lighten5, - - Colors.LightBlue.Accent1, - Colors.LightBlue.Accent2, - Colors.LightBlue.Accent3, - Colors.LightBlue.Accent4, -}; - -container - .Height(150) - .Width(420) - .Row(row => - { - foreach (var color in colors) - row.RelativeItem().Background(color); - }); -``` +<<< @/snippets/background/solid.cs{28 csharp} -![example](/api-reference/background-solid.webp) +![Fourteen equal-width stripes, each filled edge to edge with one shade of the LightBlue palette: from dark to light (Darken4 to Lighten5), then the four Accent shades.](/api-reference/background-solid.webp){.example} ## Gradient @@ -61,26 +29,9 @@ Applies a linear gradient background to the container with the specified angle a The first argument is the angle in degrees, and the second argument is an array of colors that define the gradient. -```csharp{6,10,14} -.Column(column => -{ - column.Spacing(25); - - column.Item() - .BackgroundLinearGradient(0, [Colors.Red.Lighten2, Colors.Blue.Lighten2]) - .AspectRatio(2); - - column.Item() - .BackgroundLinearGradient(45, [Colors.Green.Lighten2, Colors.LightGreen.Lighten2, Colors.Yellow.Lighten2]) - .AspectRatio(2); - - column.Item() - .BackgroundLinearGradient(90, [Colors.Yellow.Lighten2, Colors.Amber.Lighten2, Colors.Orange.Lighten2]) - .AspectRatio(2); -}); -``` +<<< @/snippets/background/gradient.cs{6,10,14 csharp} -![example](/api-reference/background-gradient.webp) +![Three gradients showing the angle convention: 0° runs from left (red) to right (blue), 45° from the top-left corner (green) to the bottom-right corner (yellow), and 90° from top (yellow) to bottom (orange).](/api-reference/background-gradient.webp){.example} ## Rounded Corners @@ -91,12 +42,6 @@ Sets the corner radius for the background, creating rounded corners. Read more about [rounded corners](/api-reference/rounded-corners.md). ::: -```csharp{2-3} -container - .Background(Colors.Grey.Lighten2) - .CornerRadius(25) - .Padding(25) - .Text("Content with rounded corners"); -``` +<<< @/snippets/background/rounded-corners.cs{3-4 csharp} -![example](/api-reference/background-rounded-corners.webp) \ No newline at end of file +![The grey background follows the rounded corners, and the box is only as wide as its padded text.](/api-reference/background-rounded-corners.webp){.example} \ No newline at end of file diff --git a/docs/api-reference/border.md b/docs/api-reference/border.md index 77cf5f9..bcf37a5 100644 --- a/docs/api-reference/border.md +++ b/docs/api-reference/border.md @@ -3,20 +3,9 @@ You can use borders to create visual separation between elements in your document. Borders can be applied to any element, including text, images, and containers. -```csharp{2} -container - .Border(3, Colors.Blue.Darken4) - .Background(Colors.Blue.Lighten5) - .Padding(25) - .Text(text => - { - text.DefaultTextStyle(x => x.FontColor(Colors.Blue.Darken4).FontSize(16)); - text.Span("TIP: ").Bold(); - text.Span("You can use borders to create visual separation between elements in your document. Borders can be applied to any element, including text, images, and containers."); - }); -``` +<<< @/snippets/border/simple.cs{2 csharp} -![example](/api-reference/border-simple.webp) +![A dark blue border surrounds the padded light blue box, and the wrapped tip text stays inside it.](/api-reference/border-simple.webp){.example} ## Thickness @@ -43,47 +32,16 @@ container.Border(1, Unit.Millimetre); ### Consistent thickness -```csharp{6,12,18} -.Row(row => -{ - row.Spacing(25); - - row.RelativeItem() - .Border(1, Colors.Black) - .Padding(10) - .AlignCenter() - .Text("Thin"); - - row.RelativeItem() - .Border(3, Colors.Black) - .Padding(10) - .AlignCenter() - .Text("Medium"); - - row.RelativeItem() - .Border(9, Colors.Black) - .Padding(10) - .AlignCenter() - .Text("Bold"); -}); -``` +<<< @/snippets/border/thickness-consistent.cs{6,12,18 csharp} -![example](/api-reference/border-thickness-consistent.webp) +![Three boxes with 1, 3 and 9 point borders: the thicker the border, the more it grows outward as well as inward, so the "Bold" box looks larger than the "Thin" one.](/api-reference/border-thickness-consistent.webp){.example} ### Various thickness -```csharp{2-5} -container - .BorderLeft(4) - .BorderTop(6) - .BorderRight(8) - .BorderBottom(10) - .Padding(25) - .Text("Sample text"); -``` +<<< @/snippets/border/thickness-various.cs{2-5 csharp} -![example](/api-reference/border-thickness-various.webp) +![Each side has its own thickness: the left edge is the thinnest and the bottom edge the thickest.](/api-reference/border-thickness-various.webp){.example} ## Solid Color @@ -92,31 +50,9 @@ In the vast majority of cases, borders are applied with a solid color. -```csharp{16} -.Row(row => -{ - var colors = new[] - { - Colors.Red.Medium, - Colors.Green.Medium, - Colors.Blue.Medium - }; - - row.Spacing(25); - - foreach (var color in colors) - { - row.RelativeItem() - .Border(5) - .BorderColor(color) - .Padding(15) - .Text(color) - .FontColor(color); - } -}); -``` +<<< @/snippets/border/color-solid.cs{16 csharp} -![example](/api-reference/border-color-solid.webp) +![Three boxes with red, green and blue borders; each shows its colour as a hex code (#F44336, #4CAF50, #2196F3) in the same colour.](/api-reference/border-color-solid.webp){.example} ## Gradient @@ -125,35 +61,9 @@ Applies a linear gradient background to the border with the specified angle and The first argument is the angle in degrees, and the second argument is an array of colors that define the gradient. -```csharp{7,14,21} -.Column(column => -{ - column.Spacing(25); - - column.Item() - .Border(5) - .BorderLinearGradient(0, [Colors.Red.Darken1, Colors.Blue.Darken1]) - .BorderAlignmentInside() - .Padding(25) - .Text("Horizontal gradient"); - - column.Item() - .Border(10) - .BorderLinearGradient(45, [Colors.Green.Darken1, Colors.LightGreen.Darken1, Colors.Yellow.Darken1]) - .BorderAlignmentInside() - .Padding(25) - .Text("Diagonal gradient"); - - column.Item() - .Border(10) - .BorderLinearGradient(90, [Colors.Yellow.Darken1, Colors.Amber.Darken1, Colors.Orange.Darken1]) - .CornerRadius(20) - .Padding(25) - .Text("Vertical gradient"); -}); -``` +<<< @/snippets/border/color-gradient.cs{7,14,21 csharp} -![example](/api-reference/border-color-gradient.webp) +![Three gradient borders: 0° runs from red on the left to blue on the right, 45° from green at the top-left to yellow at the bottom-right, and 90° from yellow at the top to orange at the bottom, following the rounded corners.](/api-reference/border-color-gradient.webp){.example} ## Alignment @@ -170,37 +80,9 @@ By default, the border is aligned to the middle of the container boundaries. However, if the border has rounded corners, the alignment is set to inside by default. -```csharp{12,18,24} -.Row(row => -{ - row.Spacing(25); - - row.RelativeItem() - .Background(Colors.Grey.Lighten1) - .Padding(25) - .Text("No Border"); - - row.RelativeItem() - .Border(10, Colors.Grey.Darken2) - .BorderAlignmentInside() - .Padding(25) - .Text("Border Inside"); - - row.RelativeItem() - .Border(10, Colors.Grey.Darken2) - .BorderAlignmentMiddle() - .Padding(25) - .Text("Border Middle"); - - row.RelativeItem() - .Border(10, Colors.Grey.Darken2) - .BorderAlignmentOutside() - .Padding(25) - .Text("Border Outside"); -}); -``` +<<< @/snippets/border/alignment.cs{12,18,24 csharp} -![example](/api-reference/border-alignment.webp) +![Four boxes with the same content: "Border Inside" keeps the size of the box without a border, "Border Middle" is larger because the border straddles the edge, and "Border Outside" is the largest because the whole border lies outside it.](/api-reference/border-alignment.webp){.example} ## Examples @@ -213,63 +95,24 @@ Borders support rounded corners, which can be applied using the `CornerRadius` m Read more about [rounded corners](/api-reference/rounded-corners.md). ::: -```csharp{2-3} -container - .CornerRadius(10) - .Border(1, Colors.Black) - .Background(Colors.Grey.Lighten2) - .Padding(25) - .Text("Border with rounded corners"); -``` +<<< @/snippets/border/rounded-corners.cs{2-3 csharp} -![example](/api-reference/border-rounded-corners-1.webp) +![A thin black border follows the rounded corners of the grey box.](/api-reference/border-rounded-corners-1.webp){.example} ### Multiple borders It is possible to apply multiple borders to the same content by separating each border instance with the `Container` method. -```csharp{6} -container - .BorderVertical(5) - .BorderColor(Colors.Green.Darken2) - .BorderAlignmentInside() - - .Container() - - .BorderHorizontal( 10) - .BorderColor(Colors.Blue.Lighten1) - .BorderAlignmentInside() - - .Background(Colors.Grey.Lighten2) - .PaddingVertical(25) - .PaddingHorizontal(50) - .Text("Content"); -``` +<<< @/snippets/border/multiple.cs{8 csharp} -![example](/api-reference/border-multiple.webp) +![Two borders on one box: green bars on the left and right run the full height, and the blue bars on the top and bottom sit between them, inside the first border.](/api-reference/border-multiple.webp){.example} ### Advanced style You can create advanced styles by combining borders with other properties, such as background color, padding, and text styles. -```csharp{2-5} -container - .CornerRadius(10) - .BorderLeft(10) - .BorderAlignmentInside() - .BorderColor(Colors.Green.Darken2) - .Background(Colors.Green.Lighten4) - .Padding(25) - .PaddingLeft(10) - .DefaultTextStyle(x => x.FontColor(Colors.Green.Darken4)) - .Column(column => - { - column.Item().Text("Completed").Bold(); - column.Item().Height(5); - column.Item().Text("The invoice has been paid in full.").FontSize(16); - }); -``` +<<< @/snippets/border/advanced-style.cs{2-5 csharp} -![example](/api-reference/border-rounded-corners-2.webp) \ No newline at end of file +![A status card: a thick green bar on the left edge, rounded together with the light green box, next to the bold title "Completed" and the line "The invoice has been paid in full."](/api-reference/border-rounded-corners-2.webp){.example} \ No newline at end of file diff --git a/docs/api-reference/debug-area.md b/docs/api-reference/debug-area.md index 58dcd58..55f5678 100644 --- a/docs/api-reference/debug-area.md +++ b/docs/api-reference/debug-area.md @@ -17,14 +17,14 @@ You can specify text and color to better distinguish between various debug eleme ```csharp{2} container - .DebugArea("Grid example", Colors.Blue.Medium) + .DebugArea("Photo gallery", Colors.Blue.Medium) // content ``` It is also possible to skip the color (it is red by default), and even the label: ```csharp -.DebugArea("Grid example") +.DebugArea("Photo gallery") .DebugArea() ``` @@ -32,27 +32,6 @@ It is also possible to skip the color (it is red by default), and even the label ## Example -```csharp{5} -container - .Width(250) - .Height(250) - .Padding(25) - .DebugArea("Grid example", Colors.Blue.Medium) - .Column(column => - { - column.Spacing(5); - - foreach (var _ in Enumerable.Range(0, 3)) - { - column.Item().Row(row => - { - row.Spacing(5); - - foreach (var _ in Enumerable.Range(0, 3)) - row.RelativeItem().Height(50).Placeholder(); - }); - } - }); -``` +<<< @/snippets/debug-area/example.cs{5 csharp} -![example](/api-reference/debug-area.webp) +![DebugArea covers the whole area it wraps with a translucent blue fill and a thin border, including the space the content doesn't use, and shows the label "Photo gallery" at the top centre.](/api-reference/debug-area.webp){.example} \ No newline at end of file diff --git a/docs/api-reference/rounded-corners.md b/docs/api-reference/rounded-corners.md index cff2bdb..3aa52cf 100644 --- a/docs/api-reference/rounded-corners.md +++ b/docs/api-reference/rounded-corners.md @@ -17,99 +17,33 @@ This feature allows you to specify the radius of the corners, giving a softer lo In the vast majority of cases, you will want to apply the same corner radius to all corners of a container. -```csharp{4} -container - .Border(1, Colors.Black) - .Background(Colors.Grey.Lighten3) - .CornerRadius(25) - .Padding(25) - .Text("Container with consistently rounded corners"); -``` +<<< @/snippets/rounded-corners/consistent.cs{4 csharp} -![example](/api-reference/rounded-corners-consistent.webp) +![All four corners are rounded with the same radius; the thin black border and the light grey background both follow the curve.](/api-reference/rounded-corners-consistent.webp){.example} ## Various Corner Radius It is also possible to apply different corner radii to each corner of a container, allowing for more complex designs. -```csharp{4-7} -container - .Border(1, Colors.Black) - .Background(Colors.Grey.Lighten3) - .CornerRadiusTopLeft(5) - .CornerRadiusTopRight(10) - .CornerRadiusBottomRight(20) - .CornerRadiusBottomLeft(40) - .Padding(25) - .Text("Container with rounded corners"); -``` +<<< @/snippets/rounded-corners/various.cs{4-7 csharp} -![example](/api-reference/rounded-corners-various.webp) +![Each corner has its own radius, from a barely rounded top-left corner to a wide curve at the bottom-left; the border and the background follow every corner.](/api-reference/rounded-corners-various.webp){.example} ## Image Example Rounded corners can also be applied to images, enhancing their appearance in documents. -```csharp{2} -container - .CornerRadius(25) - .Image("Resources/landscape.jpg"); -``` +<<< @/snippets/rounded-corners/image.cs{2 csharp} -![example](/api-reference/rounded-corners-image.webp) +![The photo is clipped to rounded corners, so its edges curve instead of meeting at sharp corners.](/api-reference/rounded-corners-image.webp){.example} ## Complex Example Rounded corners can be used in more complex layouts, such as tables, to create a polished look. -```csharp{3} -container - .Border(1, Colors.Black) - .CornerRadius(15) - .Table(table => - { - table.ColumnsDefinition(columns => - { - columns.ConstantColumn(100); - columns.RelativeColumn(); - columns.ConstantColumn(150); - }); - - table.Header(header => - { - header.Cell().Element(Style).Text("Index"); - header.Cell().Element(Style).Text("Label"); - header.Cell().Element(Style).Text("Price"); - - IContainer Style(IContainer container) - { - return container - .Border(1, Colors.Grey.Darken2) - .Background(Colors.Grey.Lighten3) - .PaddingVertical(10) - .PaddingHorizontal(15) - .DefaultTextStyle(x => x.Bold()); - } - }); - - foreach (var index in Enumerable.Range(1, 5)) - { - table.Cell().Element(Style).Text(index.ToString()); - table.Cell().Element(Style).Text(Placeholders.Label()); - table.Cell().Element(Style).Text(Placeholders.Price()); - - IContainer Style(IContainer container) - { - return container - .Border(1, Colors.Grey.Darken2) - .PaddingVertical(10) - .PaddingHorizontal(15); - } - } - }); -``` - -![example](/api-reference/rounded-corners-complex.webp) +<<< @/snippets/rounded-corners/complex.cs{3 csharp} + +![A table with a header row and five rows inside a rounded black border: the outer corners of the header and the last row are clipped to the curve, while the inner cell borders stay straight.](/api-reference/rounded-corners-complex.webp){.example} diff --git a/docs/api-reference/shadow.md b/docs/api-reference/shadow.md index cbe4505..d3d79c0 100644 --- a/docs/api-reference/shadow.md +++ b/docs/api-reference/shadow.md @@ -2,23 +2,9 @@ Shadows can enhance the visual depth and separation of elements in a document. -```csharp{3-10} -container - .Border(1, Colors.Black) - .Shadow(new BoxShadowStyle - { - Color = Colors.Grey.Medium, - Blur = 5, - Spread = 5, - OffsetX = 5, - OffsetY = 5 - }) - .Background(Colors.White) - .Padding(15) - .Text("Important content"); -``` - -![example](/api-reference/shadow-simple.webp) +<<< @/snippets/shadow/simple.cs{3-10 csharp} + +![A soft grey shadow falls below and to the right of the bordered box.](/api-reference/shadow-simple.webp){.example} ## Blur @@ -33,26 +19,9 @@ Values different from 0 may significantly impact performance and enlarge the out Use with caution, especially in large documents or when rendering complex shadows. ::: -```csharp{12} -.Row(row => -{ - row.Spacing(50); - - foreach (var blur in new[] { 5, 10, 20 }) - { - row.ConstantItem(100) - .AspectRatio(1) - .Shadow(new BoxShadowStyle - { - Color = Colors.Grey.Darken1, - Blur = blur - }) - .Background(Colors.White); - } -}); -``` +<<< @/snippets/shadow/blur.cs{12 csharp} -![example](/api-reference/shadow-blur.webp) +![Three squares with increasing blur: the shadow gets wider and softer, spreading evenly on all sides.](/api-reference/shadow-blur.webp){.example} ## Spread @@ -61,27 +30,9 @@ Gets or sets the spread radius of the shadow in points. Positive values cause the shadow to expand, negative values cause it to contract. -```csharp{13} -.Row(row => -{ - row.Spacing(50); - - foreach (var spread in new[] { 0, 5, 10 }) - { - row.ConstantItem(100) - .AspectRatio(1) - .Shadow(new BoxShadowStyle - { - Color = Colors.Grey.Darken1, - Blur = 5, - Spread = spread - }) - .Background(Colors.White); - } -}); -``` - -![example](/api-reference/shadow-spread.webp) +<<< @/snippets/shadow/spread.cs{13 csharp} + +![Three squares with increasing spread: from a faint halo to a wide, darker band around the square.](/api-reference/shadow-spread.webp){.example} ## Offset X @@ -90,27 +41,9 @@ Gets or sets the horizontal offset of the shadow in points. Positive values move the shadow to the right, negative values move it to the left. -```csharp{13} -.Row(row => -{ - row.Spacing(50); - - foreach (var offsetX in new[] { -10, 0, 10 }) - { - row.ConstantItem(100) - .AspectRatio(1) - .Shadow(new BoxShadowStyle - { - Color = Colors.Grey.Darken1, - Blur = 10, - OffsetX = offsetX - }) - .Background(Colors.White); - } -}); -``` - -![example](/api-reference/shadow-offset-x.webp) +<<< @/snippets/shadow/offset-x.cs{13 csharp} + +![A negative offset moves the shadow to the left, zero keeps it centred, and a positive offset moves it to the right.](/api-reference/shadow-offset-x.webp){.example} ## Offset Y @@ -119,60 +52,18 @@ Gets or sets the vertical offset of the shadow in points. Positive values move the shadow downward, negative values move it upward. -```csharp{13} -.Row(row => -{ - row.Spacing(50); - - foreach (var offsetY in new[] { -10, 0, 10 }) - { - row.ConstantItem(100) - .AspectRatio(1) - .Shadow(new BoxShadowStyle - { - Color = Colors.Grey.Darken2, - Blur = 10, - OffsetY = offsetY - }) - .Background(Colors.White); - } -}); -``` - -![example](/api-reference/shadow-offset-y.webp) +<<< @/snippets/shadow/offset-y.cs{13 csharp} + +![A negative offset moves the shadow up, zero keeps it centred, and a positive offset moves it down.](/api-reference/shadow-offset-y.webp){.example} ## Color Gets or sets the color of the shadow. -```csharp{18} -.Row(row => -{ - row.Spacing(50); - - var colors = new[] - { - Colors.Red.Darken2, - Colors.Green.Darken2, - Colors.Blue.Darken2 - }; - - foreach (var color in colors) - { - row.ConstantItem(100) - .AspectRatio(1) - .Shadow(new BoxShadowStyle - { - Color = color, - Blur = 10 - }) - .Background(Colors.White); - } -}); -``` - -![example](/api-reference/shadow-color.webp) +<<< @/snippets/shadow/color.cs{18 csharp} + +![Red, green and blue glows around three white squares: the shadow takes the given colour.](/api-reference/shadow-color.webp){.example} ## Without Blur (Fast) @@ -181,36 +72,6 @@ Shadows can be applied without any blur effect for a sharper appearance. This approach is faster and results in significantly smaller file sizes, making it suitable for performance-sensitive applications. -```csharp{10,22} -.Row(row => -{ - row.Spacing(50); - - row.ConstantItem(100) - .AspectRatio(1) - .Shadow(new BoxShadowStyle - { - Color = Colors.Grey.Lighten1, - Blur = 0, - OffsetX = 8, - OffsetY = 8 - }) - .Border(1, Colors.Black) - .Background(Colors.White); - - row.ConstantItem(100) - .AspectRatio(1) - .Shadow(new BoxShadowStyle - { - Color = Colors.Grey.Lighten1, - Blur = 0, - OffsetX = 8, - OffsetY = 8 - }) - .Border(1, Colors.Black) - .CornerRadius(16) - .Background(Colors.White); -}); -``` - -![example](/api-reference/shadow-no-blur.webp) \ No newline at end of file +<<< @/snippets/shadow/no-blur.cs{10,22 csharp} + +![Without blur the shadow is a solid grey copy of the shape, offset down and to the right; on the second square it follows the rounded corners.](/api-reference/shadow-no-blur.webp){.example} \ No newline at end of file diff --git a/docs/api-reference/text/basics.md b/docs/api-reference/text/basics.md index ad4c0db..9b17cb4 100644 --- a/docs/api-reference/text/basics.md +++ b/docs/api-reference/text/basics.md @@ -4,68 +4,26 @@ In most cases, text content can be added using the following shorthand. The text will inherit the default style. -```csharp -container - .Text("Hello, World!"); -``` +<<< @/snippets/text/basic.cs{csharp} -![example](/api-reference/text-basic.webp) +![Without any styling, the text uses the default style: "Sample text" in regular black letters.](/api-reference/text-basic.webp){.example} ## Customization The `Text` method returns a descriptor that allows further customization of the text style. -```csharp{7-8,12-14,18-20} -.Column(column => -{ - column.Spacing(10); - - column.Item() - .Element(CellStyle) - .Text("Text with blue color") - .FontColor(Colors.Blue.Darken1); - - column.Item() - .Element(CellStyle) - .Text("Bold and underlined text") - .Bold() - .Underline(); - - column.Item() - .Element(CellStyle) - .Text("Centered small text") - .FontSize(12) - .AlignCenter(); - - static IContainer CellStyle(IContainer container) => - container.Background(Colors.Grey.Lighten3).Padding(10); -}); -``` +<<< @/snippets/text/customization.cs{7-8,12-14,18-20 csharp} -![example](/api-reference/text-basic-descriptor.webp) +![Three grey boxes: the first text is blue, the second is bold and underlined, and the third is smaller and centred in its box.](/api-reference/text-basic-descriptor.webp){.example} ## Rich text formatting It is also possible to format specific parts of the text content using spans: -```csharp{5,7,9,11} -container - .Text(text => - { - text.Span("The "); - text.Span("chemical formula").Underline(); - text.Span(" of "); - text.Span("sulfuric acid").BackgroundColor(Colors.Amber.Lighten3); - text.Span(" is H"); - text.Span("2").Subscript(); - text.Span("SO"); - text.Span("4").Subscript(); - text.Span("."); - }); -``` +<<< @/snippets/text/rich.cs{7,9,11,13 csharp} -![example](/api-reference/text-rich.webp) +![One sentence with mixed formatting: "chemical formula" is underlined, "sulfuric acid" has a yellow highlight, and the 2 and 4 in H2SO4 are subscript.](/api-reference/text-rich.webp){.example} ## Typography pattern @@ -121,22 +79,7 @@ container Hyperlink is a clickable text that redirects the user to a specific webpage. -```csharp{8,10,12} -.Text(text => -{ - var hyperlinkStyle = TextStyle.Default - .FontColor(Colors.Blue.Medium) - .Underline(); - - text.Span("To learn more about QuestPDF, please visit its "); - text.Hyperlink("homepage", "https://www.questpdf.com/").Style(hyperlinkStyle); - text.Span(", "); - text.Hyperlink("GitHub repository", "https://github.com/QuestPDF/QuestPDF").Style(hyperlinkStyle); - text.Span(" and "); - text.Hyperlink("NuGet package page", "https://www.nuget.org/packages/QuestPDF").Style(hyperlinkStyle); - text.Span("."); -}); -``` +<<< @/snippets/text/hyperlink.cs{8,10,12 csharp}

Unable to display PDF file. Download instead.

diff --git a/docs/api-reference/text/text-style.md b/docs/api-reference/text/text-style.md index be35fa1..551b4c5 100644 --- a/docs/api-reference/text/text-style.md +++ b/docs/api-reference/text/text-style.md @@ -6,26 +6,9 @@ Font size measures the height of text characters, determining how large or small It's worth noting that different fonts may render text with different visual sizes, even when assigned the same numerical font size. -```csharp{7,11,15} -.Column(column => -{ - column.Spacing(10); +<<< @/snippets/text-style/font-size.cs{7,11,15 csharp} - column.Item() - .Text("This is small text (16pt)") - .FontSize(16); - - column.Item() - .Text("This is medium text (24pt)") - .FontSize(24); - - column.Item() - .Text("This is large text (36pt)") - .FontSize(36); -}); -``` - -![example](/api-reference/text-font-size.webp) +![Three lines of the same sentence at 16, 24 and 36 points, each one clearly larger than the last.](/api-reference/text-font-size.webp){.example} ## Font Family @@ -34,22 +17,9 @@ A font family is a collection of related fonts that share a consistent design st Examples of font families include Lato, Noto Serif and JetBrains Mono. Fonts other than the built-in Lato must be available to your application, see [font management](/api-reference/text/font-management). -```csharp{8,11} -.Column(column => -{ - column.Spacing(10); - - column.Item().Text("This is text with default font (Lato)"); +<<< @/snippets/text-style/font-family.cs{8,11 csharp} - column.Item().Text("This is text with Noto Serif font") - .FontFamily("Noto Serif"); - - column.Item().Text("This is text with JetBrains Mono font") - .FontFamily("JetBrains Mono"); -}); -``` - -![example](/api-reference/text-font-family.webp) +![The same sentence in three fonts: the default sans-serif Lato, Noto Serif with serifs, and the monospaced JetBrains Mono.](/api-reference/text-font-family.webp){.example} ## Font Fallback @@ -58,23 +28,15 @@ The Font Fallback option is a list of alternative fonts that are used when speci A common example is the display of non-Latin characters, such as Arabic or Chinese, which may not be supported by all fonts. -```csharp{3} -container - .Text("The Arabic word for programming is البرمجة.") - .FontFamily("Lato", "Noto Sans Arabic"); -``` +<<< @/snippets/text-style/font-fallback.cs{3 csharp} -![example](/api-reference/text-font-fallback.webp) +![An English sentence in Lato ends with the Arabic word البرمجة, which is drawn correctly by the fallback font instead of missing-glyph boxes.](/api-reference/text-font-fallback.webp){.example} It's also useful for displaying emojis, which are not universally supported by all fonts. -```csharp{3} -container - .Text("Popular emojis include 😊, 😂, ❤️, 👍, and 😎.") - .FontFamily("Lato", "Noto Emoji"); -``` +<<< @/snippets/text-style/font-fallback-emoji.cs{3 csharp} -![example](/api-reference/text-font-fallback-emoji.webp) +![Five emojis drawn inline with the text by the fallback font; they appear as black-and-white outlines, not in colour.](/api-reference/text-font-fallback-emoji.webp){.example} ::: tip Rather than repeating the fallback list on every text element, configure it once in the [default text style](/api-reference/default-text-style) of the page or document. @@ -87,20 +49,9 @@ The font color determines the color applied to text characters, affecting their It also influences the default color of text decorations, such as underlines. -```csharp{4,6,8} -.Text(text => -{ - text.Span("Each pixels consists of three sub-pixels: "); - text.Span("red").FontColor(Colors.Red.Medium); - text.Span(", "); - text.Span("green").FontColor(Colors.Green.Medium); - text.Span(" and "); - text.Span("blue").FontColor(Colors.Blue.Medium); - text.Span("."); -}); -``` +<<< @/snippets/text-style/font-color.cs{4,6,8 csharp} -![example](/api-reference/text-font-color.webp) +![Only the words "red", "green" and "blue" take their colours; the rest of the sentence stays black.](/api-reference/text-font-color.webp){.example} ## Background Color @@ -109,16 +60,9 @@ Sets a solid background color for the text. This color fills the area behind the text or other elements, enhancing contrast and providing visual emphasis. -```csharp{4} -.Text(text => -{ - text.Span("The term "); - text.Span("algorithm").BackgroundColor(Colors.Yellow.Lighten3).Bold(); - text.Span(" "); -}); -``` +<<< @/snippets/text-style/background-color.cs{4 csharp} -![example](/api-reference/text-font-background.webp) +![Only the bold word "algorithm" has a pale yellow background that hugs the word; the rest of the sentence wraps to a second line without a background.](/api-reference/text-font-background.webp){.example} ## Font Weight @@ -141,22 +85,9 @@ Please note that not all fonts support every weight. If the specified weight isn | ExtraBlack | 1000 | Example | -```csharp{4,6,8,10} -.Text(text => -{ - text.Span("This sentence demonstrates "); - text.Span("bold").Bold(); - text.Span(", "); - text.Span("normal").NormalWeight(); - text.Span(", "); - text.Span("light").Light(); - text.Span(" and "); - text.Span("thin").Thin(); - text.Span(" font weights."); -}); -``` +<<< @/snippets/text-style/font-weight.cs{4,6,8,10 csharp} -![example](/api-reference/text-font-weight.webp) +![Bold, normal, light and thin weights in one sentence; the thin word is barely visible.](/api-reference/text-font-weight.webp){.example} :::warning QuestPDF does not currently support fonts with variable weights. @@ -169,16 +100,9 @@ Renders text with an italic effect, where letters are slightly slanted to the ri Commonly used for emphasis or to distinguish specific words. -```csharp{4} -.Text(text => -{ - text.Span("In this sentence, the word "); - text.Span("important").Italic(); - text.Span(" is emphasized using italics."); -}); -``` +<<< @/snippets/text-style/italic.cs{4 csharp} -![example](/api-reference/text-font-italic.webp) +![The word "important" is slanted while the rest of the sentence stays upright.](/api-reference/text-font-italic.webp){.example} ## Decorations @@ -192,20 +116,9 @@ It is also possible to customize the decoration position: - Strikethrough, - Overline. -```csharp{4,6,8} -.Text(text => -{ - text.Span("There are a couple of available text decorations: "); - text.Span("underline").Underline().FontColor(Colors.Red.Medium); - text.Span(", "); - text.Span("strikethrough").Strikethrough().FontColor(Colors.Green.Medium); - text.Span(" and "); - text.Span("overline").Overline().FontColor(Colors.Blue.Medium); - text.Span(". "); -}); -``` - -![example](/api-reference/text-decoration-types.webp) +<<< @/snippets/text-style/decoration-positions.cs{4,6,8 csharp} + +![A red line below "underline", a green line through "strikethrough", and a blue line above "overline", as far above the tallest letters as the underline is below the baseline.](/api-reference/text-decoration-types.webp){.example} ### Styles @@ -216,46 +129,18 @@ It is also possible to customize the decoration line style: - DecorationDotted, - DecorationDashed. -```csharp{4,6,8,10,12} -.Text(text => -{ - text.Span("Moreover, the decoration can be "); - text.Span("solid").Underline().DecorationSolid().FontColor(Colors.Indigo.Medium); - text.Span(", "); - text.Span("double").Underline().DecorationDouble().FontColor(Colors.Blue.Medium); - text.Span(", "); - text.Span("wavy").Underline().DecorationWavy().FontColor(Colors.LightBlue.Medium); - text.Span(", "); - text.Span("dotted").Underline().DecorationDotted().FontColor(Colors.Cyan.Medium); - text.Span(" or "); - text.Span("dashed").Underline().DecorationDashed().FontColor(Colors.Green.Medium); - text.Span("."); -}); -``` - -![example](/api-reference/text-decoration-styles.webp) +<<< @/snippets/text-style/decoration-styles.cs{5,7,9,11,13-14 csharp} + +![Five underline styles under coloured words: solid, double, wavy, dotted and dashed.](/api-reference/text-decoration-styles.webp){.example} ### Styling By default, the decoration line color is the same as the text color, and the decoration thickness is determined by the font. However, these properties can be customized. -```csharp{6-9} -.Text(text => -{ - text.Span("This text contains a "); - - text.Span("seriuos") - .Underline() - .DecorationWavy() - .DecorationColor(Colors.Red.Medium) - .DecorationThickness(2); - - text.Span(" typo."); -}); -``` +<<< @/snippets/text-style/decoration-styling.cs{6-9 csharp} -![example](/api-reference/text-decoration-advanced.webp) +![A red wavy line under the misspelled word "seriuos", in a different colour from the black text.](/api-reference/text-decoration-advanced.webp){.example} ## Subscript @@ -263,16 +148,9 @@ However, these properties can be customized. Subscript displays text slightly below the baseline, often in a smaller size. Commonly used for chemical formulas or mathematical notations -```csharp{4} -.Text(text => -{ - text.Span("H"); - text.Span("2").Subscript(); - text.Span("O is the chemical formula for water."); -}); -``` +<<< @/snippets/text-style/subscript.cs{4 csharp} -![example](/api-reference/text-subscript.webp) +![The 2 in H2O is smaller and sits below the baseline.](/api-reference/text-subscript.webp){.example} ## Superscript @@ -280,16 +158,9 @@ Commonly used for chemical formulas or mathematical notations Superscript displays text slightly above the baseline, often in a smaller size. Typically used for exponents, footnotes, or ordinal indicators -```csharp{4} -.Text(text => -{ - text.Span("E = mc"); - text.Span("2").Superscript(); - text.Span(" is the equation of mass-energy equivalence."); -}); -``` +<<< @/snippets/text-style/superscript.cs{4 csharp} -![example](/api-reference/text-superscript.webp) +![The 2 in E = mc2 is smaller and raised above the baseline.](/api-reference/text-superscript.webp){.example} ## Line Height @@ -297,28 +168,9 @@ Typically used for exponents, footnotes, or ordinal indicators Adjusts the vertical spacing between lines of text, affecting readability and overall text layout. The added space is proportional to the text size. -```csharp{16} -.Column(column => -{ - column.Spacing(20); - - float[] lineHeights = [0.75f, 1f, 2f]; - var paragraph = Placeholders.Paragraph(); - - foreach (var lineHeight in lineHeights) - { - column - .Item() - .Background(Colors.Grey.Lighten3) - .Padding(5) - .Text(paragraph) - .FontSize(16) - .LineHeight(lineHeight); - } -}); -``` - -![example](/api-reference/text-line-height.webp) +<<< @/snippets/text-style/line-height.cs{16 csharp} + +![The same paragraph with three increasing line heights: in the tightest one the lines overlap, and in the widest one there is a full empty line between them.](/api-reference/text-line-height.webp){.example} ## Letter Spacing @@ -327,28 +179,9 @@ Adjusts the horizontal spacing between characters in the text, affecting readabi The adjustment is proportional to the text size. -```csharp -.Column(column => -{ - column.Spacing(20); - - var letterSpacing = new[] { -0.08f, 0f, 0.2f }; - var paragraph = Placeholders.Sentence(); - - foreach (var spacing in letterSpacing) - { - column - .Item() - .Background(Colors.Grey.Lighten3) - .Padding(5) - .Text(paragraph) - .FontSize(18) - .LetterSpacing(spacing); - } -}); -``` - -![example](/api-reference/text-letter-spacing.webp) +<<< @/snippets/text-style/letter-spacing.cs{csharp} + +![The same sentence with tighter, normal and wider letter spacing: tight letters touch each other, and wide spacing pushes the text onto a second line.](/api-reference/text-letter-spacing.webp){.example} ## Word Spacing @@ -356,27 +189,9 @@ The adjustment is proportional to the text size. Adjusts the horizontal spacing between words in the text, affecting readability and overall visual style. The adjustment is proportional to the text size. -```csharp -.Column(column => -{ - column.Spacing(20); - - var wordSpacing = new[] { -0.2f, 0f, 0.4f }; - var paragraph = Placeholders.Sentence(); - - foreach (var spacing in wordSpacing) - { - column.Item() - .Background(Colors.Grey.Lighten3) - .Padding(5) - .Text(paragraph) - .FontSize(16) - .WordSpacing(spacing); - } -}); -``` - -![example](/api-reference/text-word-spacing.webp) +<<< @/snippets/text-style/word-spacing.cs{csharp} + +![Negative word spacing removes the gaps between words, normal spacing keeps them, and positive spacing widens them.](/api-reference/text-word-spacing.webp){.example} ## Hyphenation @@ -387,24 +202,9 @@ It does not hyphenate text automatically. Please use a dedicated hyphenation lib A soft hyphen is invisible and is rendered only when the line actually breaks at that position. This behavior is always enabled and requires no configuration. -```csharp -.Column(column => -{ - column.Spacing(20); - - column.Item() - .Background(Colors.Grey.Lighten3) - .Text("Bitte aktualisieren Sie die Zugriffsberechtigungen in der Serverkonfigurationsdatei."); +<<< @/snippets/text-style/hyphenation.cs{csharp} - column.Item() - .Background(Colors.Grey.Lighten3) - .Text("Bit\u00ADte ak\u00ADtua\u00ADli\u00ADsie\u00ADren Sie die " + - "Zu\u00ADgriffs\u00ADbe\u00ADrech\u00ADti\u00ADgun\u00ADgen in der " + - "Ser\u00ADver\u00ADkon\u00ADfi\u00ADgu\u00ADra\u00ADti\u00ADons\u00ADda\u00ADtei."); -}); -``` - -![example](/api-reference/text-hyphenation.webp) +![Without soft hyphens the long German words move to the next line whole; with them, the words break at the soft hyphens and a hyphen is drawn at each break.](/api-reference/text-hyphenation.webp){.example} ## Font Features @@ -429,39 +229,9 @@ QuestPDF disables the `StandardLigatures` feature by default. Enable it explicit Let's analyze the `StandardLigatures` font feature, which replaces specific pairs of letters (such as 'fi' or 'fl') with a single, combined glyph to enhance aesthetics. -```csharp{15,27} -.Row(row => -{ - row.Spacing(25); - - row.RelativeItem() - .Background(Colors.Grey.Lighten3) - .Padding(10) - .Column(column => - { - column.Item().Text("Without ligatures").FontSize(16); - - column.Item() - .Text("fly and fight") - .FontSize(32) - .DisableFontFeature(FontFeatures.StandardLigatures); - }); - - row.RelativeItem() - .Background(Colors.Grey.Lighten3) - .Padding(10) - .Column(column => - { - column.Item().Text("With ligatures").FontSize(16); - - column.Item().Text("fly and fight") - .FontSize(32) - .EnableFontFeature(FontFeatures.StandardLigatures); - }); -}); -``` - -![example](/api-reference/text-font-features.webp) +<<< @/snippets/text-style/font-features.cs{15,27 csharp} + +![Without ligatures, "fl" and "fi" are separate letters; with ligatures, each pair is joined into a single glyph.](/api-reference/text-font-features.webp){.example} ## Break Anywhere @@ -472,20 +242,6 @@ With this setting enabled, lines are filled as fully as possible, at the cost of Without this setting, a word longer than the line is still split where it overflows, so no text is cut off. `BreakAnywhere` changes where lines break: they are filled completely instead of breaking early at natural break points such as `/` or `-`. Use it when evenly filled lines matter more than readable breaks, e.g. hashes or identifiers in narrow columns; for prose and URLs the default is usually easier to read. -```csharp -.Column(column => -{ - column.Spacing(20); - - column.Item() - .Background(Colors.Grey.Lighten3) - .Text("https://www.questpdf.com/api-reference/text/font-management.html#manual-font-registration"); - - column.Item() - .Background(Colors.Grey.Lighten3) - .Text("https://www.questpdf.com/api-reference/text/font-management.html#manual-font-registration") - .BreakAnywhere(); -}); -``` +<<< @/snippets/text-style/break-anywhere.cs{csharp} -![example](/api-reference/text-break-anywhere.webp) \ No newline at end of file +![By default the URL breaks after "-" and "/", leaving uneven lines; with BreakAnywhere every line is filled and words are split at any character, such as "api-ref" / "erence".](/api-reference/text-break-anywhere.webp){.example} \ No newline at end of file diff --git a/docs/public/api-reference/background-gradient.webp b/docs/public/api-reference/background-gradient.webp index 24473f9..dd486ab 100644 Binary files a/docs/public/api-reference/background-gradient.webp and b/docs/public/api-reference/background-gradient.webp differ diff --git a/docs/public/api-reference/background-rounded-corners.webp b/docs/public/api-reference/background-rounded-corners.webp index f9df231..f475b74 100644 Binary files a/docs/public/api-reference/background-rounded-corners.webp and b/docs/public/api-reference/background-rounded-corners.webp differ diff --git a/docs/public/api-reference/border-alignment.webp b/docs/public/api-reference/border-alignment.webp index 26050d5..20d3c4e 100644 Binary files a/docs/public/api-reference/border-alignment.webp and b/docs/public/api-reference/border-alignment.webp differ diff --git a/docs/public/api-reference/border-color-gradient.webp b/docs/public/api-reference/border-color-gradient.webp index b442447..0e80e95 100644 Binary files a/docs/public/api-reference/border-color-gradient.webp and b/docs/public/api-reference/border-color-gradient.webp differ diff --git a/docs/public/api-reference/border-color-solid.webp b/docs/public/api-reference/border-color-solid.webp index ecf4645..8394ed7 100644 Binary files a/docs/public/api-reference/border-color-solid.webp and b/docs/public/api-reference/border-color-solid.webp differ diff --git a/docs/public/api-reference/border-multiple.webp b/docs/public/api-reference/border-multiple.webp index b6d1847..da06e28 100644 Binary files a/docs/public/api-reference/border-multiple.webp and b/docs/public/api-reference/border-multiple.webp differ diff --git a/docs/public/api-reference/border-rounded-corners-1.webp b/docs/public/api-reference/border-rounded-corners-1.webp index ef89f62..f20fc7e 100644 Binary files a/docs/public/api-reference/border-rounded-corners-1.webp and b/docs/public/api-reference/border-rounded-corners-1.webp differ diff --git a/docs/public/api-reference/border-rounded-corners-2.webp b/docs/public/api-reference/border-rounded-corners-2.webp index b5492da..0a11ed2 100644 Binary files a/docs/public/api-reference/border-rounded-corners-2.webp and b/docs/public/api-reference/border-rounded-corners-2.webp differ diff --git a/docs/public/api-reference/border-simple.webp b/docs/public/api-reference/border-simple.webp index de42259..bbca03b 100644 Binary files a/docs/public/api-reference/border-simple.webp and b/docs/public/api-reference/border-simple.webp differ diff --git a/docs/public/api-reference/border-thickness-consistent.webp b/docs/public/api-reference/border-thickness-consistent.webp index 1a2ccc5..b2db1d3 100644 Binary files a/docs/public/api-reference/border-thickness-consistent.webp and b/docs/public/api-reference/border-thickness-consistent.webp differ diff --git a/docs/public/api-reference/border-thickness-various.webp b/docs/public/api-reference/border-thickness-various.webp index 74dc049..3ce55a0 100644 Binary files a/docs/public/api-reference/border-thickness-various.webp and b/docs/public/api-reference/border-thickness-various.webp differ diff --git a/docs/public/api-reference/debug-area.webp b/docs/public/api-reference/debug-area.webp index 429101b..0481734 100644 Binary files a/docs/public/api-reference/debug-area.webp and b/docs/public/api-reference/debug-area.webp differ diff --git a/docs/public/api-reference/rounded-corners-complex.webp b/docs/public/api-reference/rounded-corners-complex.webp index 9375d9f..a09ef85 100644 Binary files a/docs/public/api-reference/rounded-corners-complex.webp and b/docs/public/api-reference/rounded-corners-complex.webp differ diff --git a/docs/public/api-reference/rounded-corners-consistent.webp b/docs/public/api-reference/rounded-corners-consistent.webp index e217424..8fe048d 100644 Binary files a/docs/public/api-reference/rounded-corners-consistent.webp and b/docs/public/api-reference/rounded-corners-consistent.webp differ diff --git a/docs/public/api-reference/rounded-corners-image.webp b/docs/public/api-reference/rounded-corners-image.webp index 1f5f913..2b3a02e 100644 Binary files a/docs/public/api-reference/rounded-corners-image.webp and b/docs/public/api-reference/rounded-corners-image.webp differ diff --git a/docs/public/api-reference/rounded-corners-various.webp b/docs/public/api-reference/rounded-corners-various.webp index fadc8e9..77dde02 100644 Binary files a/docs/public/api-reference/rounded-corners-various.webp and b/docs/public/api-reference/rounded-corners-various.webp differ diff --git a/docs/public/api-reference/shadow-blur.webp b/docs/public/api-reference/shadow-blur.webp index 60dfd11..840a720 100644 Binary files a/docs/public/api-reference/shadow-blur.webp and b/docs/public/api-reference/shadow-blur.webp differ diff --git a/docs/public/api-reference/shadow-color.webp b/docs/public/api-reference/shadow-color.webp index 8fb5d6a..8c3071c 100644 Binary files a/docs/public/api-reference/shadow-color.webp and b/docs/public/api-reference/shadow-color.webp differ diff --git a/docs/public/api-reference/shadow-no-blur.webp b/docs/public/api-reference/shadow-no-blur.webp index 1aafb7f..383b476 100644 Binary files a/docs/public/api-reference/shadow-no-blur.webp and b/docs/public/api-reference/shadow-no-blur.webp differ diff --git a/docs/public/api-reference/shadow-offset-x.webp b/docs/public/api-reference/shadow-offset-x.webp index a6fa69c..8db3601 100644 Binary files a/docs/public/api-reference/shadow-offset-x.webp and b/docs/public/api-reference/shadow-offset-x.webp differ diff --git a/docs/public/api-reference/shadow-offset-y.webp b/docs/public/api-reference/shadow-offset-y.webp index e092008..d77f29b 100644 Binary files a/docs/public/api-reference/shadow-offset-y.webp and b/docs/public/api-reference/shadow-offset-y.webp differ diff --git a/docs/public/api-reference/shadow-simple.webp b/docs/public/api-reference/shadow-simple.webp index cfdfd93..ba7f683 100644 Binary files a/docs/public/api-reference/shadow-simple.webp and b/docs/public/api-reference/shadow-simple.webp differ diff --git a/docs/public/api-reference/shadow-spread.webp b/docs/public/api-reference/shadow-spread.webp index 2dd89b4..10b1adb 100644 Binary files a/docs/public/api-reference/shadow-spread.webp and b/docs/public/api-reference/shadow-spread.webp differ diff --git a/docs/public/api-reference/text-basic-descriptor.webp b/docs/public/api-reference/text-basic-descriptor.webp index 23938f3..77acf2c 100644 Binary files a/docs/public/api-reference/text-basic-descriptor.webp and b/docs/public/api-reference/text-basic-descriptor.webp differ diff --git a/docs/public/api-reference/text-basic.webp b/docs/public/api-reference/text-basic.webp index 8b8cb5a..e9ef2ea 100644 Binary files a/docs/public/api-reference/text-basic.webp and b/docs/public/api-reference/text-basic.webp differ diff --git a/docs/public/api-reference/text-break-anywhere.webp b/docs/public/api-reference/text-break-anywhere.webp index 58e2135..e2ee3e7 100644 Binary files a/docs/public/api-reference/text-break-anywhere.webp and b/docs/public/api-reference/text-break-anywhere.webp differ diff --git a/docs/public/api-reference/text-decoration-advanced.webp b/docs/public/api-reference/text-decoration-advanced.webp index e2ba23c..39b7bd0 100644 Binary files a/docs/public/api-reference/text-decoration-advanced.webp and b/docs/public/api-reference/text-decoration-advanced.webp differ diff --git a/docs/public/api-reference/text-decoration-styles.webp b/docs/public/api-reference/text-decoration-styles.webp index 74989a7..799d3af 100644 Binary files a/docs/public/api-reference/text-decoration-styles.webp and b/docs/public/api-reference/text-decoration-styles.webp differ diff --git a/docs/public/api-reference/text-decoration-types.webp b/docs/public/api-reference/text-decoration-types.webp index ec29f20..cdc9afc 100644 Binary files a/docs/public/api-reference/text-decoration-types.webp and b/docs/public/api-reference/text-decoration-types.webp differ diff --git a/docs/public/api-reference/text-font-background.webp b/docs/public/api-reference/text-font-background.webp index 32025d6..350765f 100644 Binary files a/docs/public/api-reference/text-font-background.webp and b/docs/public/api-reference/text-font-background.webp differ diff --git a/docs/public/api-reference/text-font-color.webp b/docs/public/api-reference/text-font-color.webp index 58d56a8..148853c 100644 Binary files a/docs/public/api-reference/text-font-color.webp and b/docs/public/api-reference/text-font-color.webp differ diff --git a/docs/public/api-reference/text-font-fallback-emoji.webp b/docs/public/api-reference/text-font-fallback-emoji.webp index c0bd797..76a21d7 100644 Binary files a/docs/public/api-reference/text-font-fallback-emoji.webp and b/docs/public/api-reference/text-font-fallback-emoji.webp differ diff --git a/docs/public/api-reference/text-font-fallback.webp b/docs/public/api-reference/text-font-fallback.webp index 405ca92..a9e6f1d 100644 Binary files a/docs/public/api-reference/text-font-fallback.webp and b/docs/public/api-reference/text-font-fallback.webp differ diff --git a/docs/public/api-reference/text-font-features.webp b/docs/public/api-reference/text-font-features.webp index e3bbb3d..4149ba8 100644 Binary files a/docs/public/api-reference/text-font-features.webp and b/docs/public/api-reference/text-font-features.webp differ diff --git a/docs/public/api-reference/text-font-italic.webp b/docs/public/api-reference/text-font-italic.webp index c04678b..cc69572 100644 Binary files a/docs/public/api-reference/text-font-italic.webp and b/docs/public/api-reference/text-font-italic.webp differ diff --git a/docs/public/api-reference/text-font-size.webp b/docs/public/api-reference/text-font-size.webp index 2ed2470..3398793 100644 Binary files a/docs/public/api-reference/text-font-size.webp and b/docs/public/api-reference/text-font-size.webp differ diff --git a/docs/public/api-reference/text-font-weight.webp b/docs/public/api-reference/text-font-weight.webp index b03ca87..be33b24 100644 Binary files a/docs/public/api-reference/text-font-weight.webp and b/docs/public/api-reference/text-font-weight.webp differ diff --git a/docs/public/api-reference/text-hyphenation.webp b/docs/public/api-reference/text-hyphenation.webp index 457a994..2e100d8 100644 Binary files a/docs/public/api-reference/text-hyphenation.webp and b/docs/public/api-reference/text-hyphenation.webp differ diff --git a/docs/public/api-reference/text-letter-spacing.webp b/docs/public/api-reference/text-letter-spacing.webp index 45ff58a..3a89114 100644 Binary files a/docs/public/api-reference/text-letter-spacing.webp and b/docs/public/api-reference/text-letter-spacing.webp differ diff --git a/docs/public/api-reference/text-line-height.webp b/docs/public/api-reference/text-line-height.webp index e0c1319..6248c07 100644 Binary files a/docs/public/api-reference/text-line-height.webp and b/docs/public/api-reference/text-line-height.webp differ diff --git a/docs/public/api-reference/text-rich.webp b/docs/public/api-reference/text-rich.webp index b210ea5..d447f60 100644 Binary files a/docs/public/api-reference/text-rich.webp and b/docs/public/api-reference/text-rich.webp differ diff --git a/docs/public/api-reference/text-subscript.webp b/docs/public/api-reference/text-subscript.webp index 964172d..34d74c8 100644 Binary files a/docs/public/api-reference/text-subscript.webp and b/docs/public/api-reference/text-subscript.webp differ diff --git a/docs/public/api-reference/text-superscript.webp b/docs/public/api-reference/text-superscript.webp index cf991ad..56453fa 100644 Binary files a/docs/public/api-reference/text-superscript.webp and b/docs/public/api-reference/text-superscript.webp differ diff --git a/docs/public/api-reference/text-word-spacing.webp b/docs/public/api-reference/text-word-spacing.webp index 64ee2c3..f001266 100644 Binary files a/docs/public/api-reference/text-word-spacing.webp and b/docs/public/api-reference/text-word-spacing.webp differ diff --git a/docs/snippets/background/gradient.cs b/docs/snippets/background/gradient.cs new file mode 100644 index 0000000..3a078bf --- /dev/null +++ b/docs/snippets/background/gradient.cs @@ -0,0 +1,16 @@ +.Column(column => +{ + column.Spacing(25); + + column.Item() + .BackgroundLinearGradient(0, [Colors.Red.Lighten2, Colors.Blue.Lighten2]) + .AspectRatio(2); + + column.Item() + .BackgroundLinearGradient(45, [Colors.Green.Lighten2, Colors.LightGreen.Lighten2, Colors.Yellow.Lighten2]) + .AspectRatio(2); + + column.Item() + .BackgroundLinearGradient(90, [Colors.Yellow.Lighten2, Colors.Amber.Lighten2, Colors.Orange.Lighten2]) + .AspectRatio(2); +}); diff --git a/docs/snippets/background/rounded-corners.cs b/docs/snippets/background/rounded-corners.cs new file mode 100644 index 0000000..69ad316 --- /dev/null +++ b/docs/snippets/background/rounded-corners.cs @@ -0,0 +1,6 @@ +container + .Shrink() + .Background(Colors.Grey.Lighten2) + .CornerRadius(25) + .Padding(25) + .Text("Content with rounded corners"); diff --git a/docs/snippets/background/solid.cs b/docs/snippets/background/solid.cs new file mode 100644 index 0000000..957bf9e --- /dev/null +++ b/docs/snippets/background/solid.cs @@ -0,0 +1,29 @@ +var colors = new[] +{ + Colors.LightBlue.Darken4, + Colors.LightBlue.Darken3, + Colors.LightBlue.Darken2, + Colors.LightBlue.Darken1, + + Colors.LightBlue.Medium, + + Colors.LightBlue.Lighten1, + Colors.LightBlue.Lighten2, + Colors.LightBlue.Lighten3, + Colors.LightBlue.Lighten4, + Colors.LightBlue.Lighten5, + + Colors.LightBlue.Accent1, + Colors.LightBlue.Accent2, + Colors.LightBlue.Accent3, + Colors.LightBlue.Accent4, +}; + +page.Content() + .Height(150) + .Width(420) + .Row(row => + { + foreach (var color in colors) + row.RelativeItem().Background(color); + }); diff --git a/docs/snippets/border/advanced-style.cs b/docs/snippets/border/advanced-style.cs new file mode 100644 index 0000000..b3db05c --- /dev/null +++ b/docs/snippets/border/advanced-style.cs @@ -0,0 +1,15 @@ +container + .CornerRadius(10) + .BorderLeft(10) + .BorderAlignmentInside() + .BorderColor(Colors.Green.Darken2) + .Background(Colors.Green.Lighten4) + .Padding(25) + .PaddingLeft(10) + .DefaultTextStyle(x => x.FontColor(Colors.Green.Darken4)) + .Column(column => + { + column.Item().Text("Completed").Bold(); + column.Item().Height(5); + column.Item().Text("The invoice has been paid in full.").FontSize(16); + }); diff --git a/docs/snippets/border/alignment.cs b/docs/snippets/border/alignment.cs new file mode 100644 index 0000000..9120266 --- /dev/null +++ b/docs/snippets/border/alignment.cs @@ -0,0 +1,27 @@ +.Row(row => +{ + row.Spacing(25); + + row.RelativeItem() + .Background(Colors.Grey.Lighten1) + .Padding(25) + .Text("No Border"); + + row.RelativeItem() + .Border(10, Colors.Grey.Darken2) + .BorderAlignmentInside() + .Padding(25) + .Text("Border Inside"); + + row.RelativeItem() + .Border(10, Colors.Grey.Darken2) + .BorderAlignmentMiddle() + .Padding(25) + .Text("Border Middle"); + + row.RelativeItem() + .Border(10, Colors.Grey.Darken2) + .BorderAlignmentOutside() + .Padding(25) + .Text("Border Outside"); +}); diff --git a/docs/snippets/border/color-gradient.cs b/docs/snippets/border/color-gradient.cs new file mode 100644 index 0000000..d0e571f --- /dev/null +++ b/docs/snippets/border/color-gradient.cs @@ -0,0 +1,25 @@ +.Column(column => +{ + column.Spacing(25); + + column.Item() + .Border(5) + .BorderLinearGradient(0, [Colors.Red.Darken1, Colors.Blue.Darken1]) + .BorderAlignmentInside() + .Padding(25) + .Text("Horizontal gradient"); + + column.Item() + .Border(10) + .BorderLinearGradient(45, [Colors.Green.Darken1, Colors.LightGreen.Darken1, Colors.Yellow.Darken1]) + .BorderAlignmentInside() + .Padding(25) + .Text("Diagonal gradient"); + + column.Item() + .Border(10) + .BorderLinearGradient(90, [Colors.Yellow.Darken1, Colors.Amber.Darken1, Colors.Orange.Darken1]) + .CornerRadius(20) + .Padding(25) + .Text("Vertical gradient"); +}); diff --git a/docs/snippets/border/color-solid.cs b/docs/snippets/border/color-solid.cs new file mode 100644 index 0000000..76efc24 --- /dev/null +++ b/docs/snippets/border/color-solid.cs @@ -0,0 +1,21 @@ +.Row(row => +{ + var colors = new[] + { + Colors.Red.Medium, + Colors.Green.Medium, + Colors.Blue.Medium + }; + + row.Spacing(25); + + foreach (var color in colors) + { + row.RelativeItem() + .Border(5) + .BorderColor(color) + .Padding(15) + .Text(color) + .FontColor(color); + } +}); diff --git a/docs/snippets/border/multiple.cs b/docs/snippets/border/multiple.cs new file mode 100644 index 0000000..f2fb806 --- /dev/null +++ b/docs/snippets/border/multiple.cs @@ -0,0 +1,17 @@ +container + .Shrink() + + .BorderVertical(5) + .BorderColor(Colors.Green.Darken2) + .BorderAlignmentInside() + + .Container() + + .BorderHorizontal( 10) + .BorderColor(Colors.Blue.Lighten1) + .BorderAlignmentInside() + + .Background(Colors.Grey.Lighten2) + .PaddingVertical(25) + .PaddingHorizontal(50) + .Text("Content"); diff --git a/docs/snippets/border/rounded-corners.cs b/docs/snippets/border/rounded-corners.cs new file mode 100644 index 0000000..1497918 --- /dev/null +++ b/docs/snippets/border/rounded-corners.cs @@ -0,0 +1,6 @@ +container + .CornerRadius(10) + .Border(1, Colors.Black) + .Background(Colors.Grey.Lighten2) + .Padding(25) + .Text("Border with rounded corners"); diff --git a/docs/snippets/border/simple.cs b/docs/snippets/border/simple.cs new file mode 100644 index 0000000..e5e20aa --- /dev/null +++ b/docs/snippets/border/simple.cs @@ -0,0 +1,10 @@ +container + .Border(3, Colors.Blue.Darken4) + .Background(Colors.Blue.Lighten5) + .Padding(25) + .Text(text => + { + text.DefaultTextStyle(x => x.FontColor(Colors.Blue.Darken4).FontSize(16)); + text.Span("TIP: ").Bold(); + text.Span("You can use borders to create visual separation between elements in your document. Borders can be applied to any element, including text, images, and containers."); + }); diff --git a/docs/snippets/border/thickness-consistent.cs b/docs/snippets/border/thickness-consistent.cs new file mode 100644 index 0000000..f4891dd --- /dev/null +++ b/docs/snippets/border/thickness-consistent.cs @@ -0,0 +1,22 @@ +.Row(row => +{ + row.Spacing(25); + + row.RelativeItem() + .Border(1, Colors.Black) + .Padding(10) + .AlignCenter() + .Text("Thin"); + + row.RelativeItem() + .Border(3, Colors.Black) + .Padding(10) + .AlignCenter() + .Text("Medium"); + + row.RelativeItem() + .Border(9, Colors.Black) + .Padding(10) + .AlignCenter() + .Text("Bold"); +}); diff --git a/docs/snippets/border/thickness-various.cs b/docs/snippets/border/thickness-various.cs new file mode 100644 index 0000000..1c3d83e --- /dev/null +++ b/docs/snippets/border/thickness-various.cs @@ -0,0 +1,7 @@ +container + .BorderLeft(4) + .BorderTop(6) + .BorderRight(8) + .BorderBottom(10) + .Padding(25) + .Text("Sample text"); diff --git a/docs/snippets/debug-area/example.cs b/docs/snippets/debug-area/example.cs new file mode 100644 index 0000000..68c28f5 --- /dev/null +++ b/docs/snippets/debug-area/example.cs @@ -0,0 +1,20 @@ +container + .Width(250) + .Height(250) + .Padding(25) + .DebugArea("Photo gallery", Colors.Blue.Medium) + .Column(column => + { + column.Spacing(5); + + foreach (var _ in Enumerable.Range(0, 3)) + { + column.Item().Row(row => + { + row.Spacing(5); + + foreach (var _ in Enumerable.Range(0, 3)) + row.RelativeItem().Height(50).Placeholder(); + }); + } + }); diff --git a/docs/snippets/rounded-corners/complex.cs b/docs/snippets/rounded-corners/complex.cs new file mode 100644 index 0000000..cada9ac --- /dev/null +++ b/docs/snippets/rounded-corners/complex.cs @@ -0,0 +1,53 @@ +container + .Border(1, Colors.Black) + .CornerRadius(15) + .Table(table => + { + table.ColumnsDefinition(columns => + { + columns.ConstantColumn(100); + columns.RelativeColumn(); + columns.ConstantColumn(150); + }); + + table.Header(header => + { + header.Cell().Element(Style).Text("Index"); + header.Cell().Element(Style).Text("Label"); + header.Cell().Element(Style).Text("Price"); + + IContainer Style(IContainer container) + { + return container + .Border(1, Colors.Grey.Darken2) + .Background(Colors.Grey.Lighten3) + .PaddingVertical(10) + .PaddingHorizontal(15) + .DefaultTextStyle(x => x.Bold()); + } + }); + + var products = new[] + { + (Index: 1, Label: "Desk lamp", Price: "$34.99"), + (Index: 2, Label: "Notebook", Price: "$4.99"), + (Index: 3, Label: "Fountain pen", Price: "$59.00"), + (Index: 4, Label: "Paper clips", Price: "$1.49"), + (Index: 5, Label: "Monitor stand", Price: "$89.00") + }; + + foreach (var product in products) + { + table.Cell().Element(Style).Text(product.Index.ToString()); + table.Cell().Element(Style).Text(product.Label); + table.Cell().Element(Style).Text(product.Price); + + IContainer Style(IContainer container) + { + return container + .Border(1, Colors.Grey.Darken2) + .PaddingVertical(10) + .PaddingHorizontal(15); + } + } + }); diff --git a/docs/snippets/rounded-corners/consistent.cs b/docs/snippets/rounded-corners/consistent.cs new file mode 100644 index 0000000..5324fd6 --- /dev/null +++ b/docs/snippets/rounded-corners/consistent.cs @@ -0,0 +1,6 @@ +container + .Border(1, Colors.Black) + .Background(Colors.Grey.Lighten3) + .CornerRadius(25) + .Padding(25) + .Text("Container with consistently rounded corners"); diff --git a/docs/snippets/rounded-corners/image.cs b/docs/snippets/rounded-corners/image.cs new file mode 100644 index 0000000..6294a52 --- /dev/null +++ b/docs/snippets/rounded-corners/image.cs @@ -0,0 +1,3 @@ +container + .CornerRadius(25) + .Image("Resources/landscape.jpg"); diff --git a/docs/snippets/rounded-corners/various.cs b/docs/snippets/rounded-corners/various.cs new file mode 100644 index 0000000..5a4aaf5 --- /dev/null +++ b/docs/snippets/rounded-corners/various.cs @@ -0,0 +1,9 @@ +container + .Border(1, Colors.Black) + .Background(Colors.Grey.Lighten3) + .CornerRadiusTopLeft(5) + .CornerRadiusTopRight(10) + .CornerRadiusBottomRight(20) + .CornerRadiusBottomLeft(40) + .Padding(25) + .Text("Container with rounded corners"); diff --git a/docs/snippets/shadow/blur.cs b/docs/snippets/shadow/blur.cs new file mode 100644 index 0000000..dd251fe --- /dev/null +++ b/docs/snippets/shadow/blur.cs @@ -0,0 +1,16 @@ +.Row(row => +{ + row.Spacing(50); + + foreach (var blur in new[] { 5, 10, 20 }) + { + row.ConstantItem(100) + .AspectRatio(1) + .Shadow(new BoxShadowStyle + { + Color = Colors.Grey.Darken1, + Blur = blur + }) + .Background(Colors.White); + } +}); diff --git a/docs/snippets/shadow/color.cs b/docs/snippets/shadow/color.cs new file mode 100644 index 0000000..69e6295 --- /dev/null +++ b/docs/snippets/shadow/color.cs @@ -0,0 +1,23 @@ +.Row(row => +{ + row.Spacing(50); + + var colors = new[] + { + Colors.Red.Darken2, + Colors.Green.Darken2, + Colors.Blue.Darken2 + }; + + foreach (var color in colors) + { + row.ConstantItem(100) + .AspectRatio(1) + .Shadow(new BoxShadowStyle + { + Color = color, + Blur = 10 + }) + .Background(Colors.White); + } +}); diff --git a/docs/snippets/shadow/no-blur.cs b/docs/snippets/shadow/no-blur.cs new file mode 100644 index 0000000..03fcbcd --- /dev/null +++ b/docs/snippets/shadow/no-blur.cs @@ -0,0 +1,29 @@ +.Row(row => +{ + row.Spacing(50); + + row.ConstantItem(100) + .AspectRatio(1) + .Shadow(new BoxShadowStyle + { + Color = Colors.Grey.Lighten1, + Blur = 0, + OffsetX = 8, + OffsetY = 8 + }) + .Border(1, Colors.Black) + .Background(Colors.White); + + row.ConstantItem(100) + .AspectRatio(1) + .Shadow(new BoxShadowStyle + { + Color = Colors.Grey.Lighten1, + Blur = 0, + OffsetX = 8, + OffsetY = 8 + }) + .Border(1, Colors.Black) + .CornerRadius(16) + .Background(Colors.White); +}); diff --git a/docs/snippets/shadow/offset-x.cs b/docs/snippets/shadow/offset-x.cs new file mode 100644 index 0000000..265155f --- /dev/null +++ b/docs/snippets/shadow/offset-x.cs @@ -0,0 +1,17 @@ +.Row(row => +{ + row.Spacing(50); + + foreach (var offsetX in new[] { -10, 0, 10 }) + { + row.ConstantItem(100) + .AspectRatio(1) + .Shadow(new BoxShadowStyle + { + Color = Colors.Grey.Darken1, + Blur = 10, + OffsetX = offsetX + }) + .Background(Colors.White); + } +}); diff --git a/docs/snippets/shadow/offset-y.cs b/docs/snippets/shadow/offset-y.cs new file mode 100644 index 0000000..45fe80f --- /dev/null +++ b/docs/snippets/shadow/offset-y.cs @@ -0,0 +1,17 @@ +.Row(row => +{ + row.Spacing(50); + + foreach (var offsetY in new[] { -10, 0, 10 }) + { + row.ConstantItem(100) + .AspectRatio(1) + .Shadow(new BoxShadowStyle + { + Color = Colors.Grey.Darken2, + Blur = 10, + OffsetY = offsetY + }) + .Background(Colors.White); + } +}); diff --git a/docs/snippets/shadow/simple.cs b/docs/snippets/shadow/simple.cs new file mode 100644 index 0000000..0997feb --- /dev/null +++ b/docs/snippets/shadow/simple.cs @@ -0,0 +1,13 @@ +container + .Border(1, Colors.Black) + .Shadow(new BoxShadowStyle + { + Color = Colors.Grey.Medium, + Blur = 5, + Spread = 5, + OffsetX = 5, + OffsetY = 5 + }) + .Background(Colors.White) + .Padding(15) + .Text("Important content"); diff --git a/docs/snippets/shadow/spread.cs b/docs/snippets/shadow/spread.cs new file mode 100644 index 0000000..5d957a5 --- /dev/null +++ b/docs/snippets/shadow/spread.cs @@ -0,0 +1,17 @@ +.Row(row => +{ + row.Spacing(50); + + foreach (var spread in new[] { 0, 5, 10 }) + { + row.ConstantItem(100) + .AspectRatio(1) + .Shadow(new BoxShadowStyle + { + Color = Colors.Grey.Darken1, + Blur = 5, + Spread = spread + }) + .Background(Colors.White); + } +}); diff --git a/docs/snippets/text-style/background-color.cs b/docs/snippets/text-style/background-color.cs new file mode 100644 index 0000000..a79d67b --- /dev/null +++ b/docs/snippets/text-style/background-color.cs @@ -0,0 +1,6 @@ +.Text(text => +{ + text.Span("The term "); + text.Span("algorithm").BackgroundColor(Colors.Yellow.Lighten3).Bold(); + text.Span(" refers to a set of rules or steps used to solve a problem."); +}); diff --git a/docs/snippets/text-style/break-anywhere.cs b/docs/snippets/text-style/break-anywhere.cs new file mode 100644 index 0000000..a68e648 --- /dev/null +++ b/docs/snippets/text-style/break-anywhere.cs @@ -0,0 +1,13 @@ +.Column(column => +{ + column.Spacing(20); + + column.Item() + .Background(Colors.Grey.Lighten3) + .Text("https://www.questpdf.com/api-reference/text/font-management.html#manual-font-registration"); + + column.Item() + .Background(Colors.Grey.Lighten3) + .Text("https://www.questpdf.com/api-reference/text/font-management.html#manual-font-registration") + .BreakAnywhere(); +}); diff --git a/docs/snippets/text-style/decoration-positions.cs b/docs/snippets/text-style/decoration-positions.cs new file mode 100644 index 0000000..2a121a0 --- /dev/null +++ b/docs/snippets/text-style/decoration-positions.cs @@ -0,0 +1,10 @@ +.Text(text => +{ + text.Span("There are a couple of available text decorations: "); + text.Span("underline").Underline().FontColor(Colors.Red.Medium); + text.Span(", "); + text.Span("strikethrough").Strikethrough().FontColor(Colors.Green.Medium); + text.Span(" and "); + text.Span("overline").Overline().FontColor(Colors.Blue.Medium); + text.Span(". "); +}); diff --git a/docs/snippets/text-style/decoration-styles.cs b/docs/snippets/text-style/decoration-styles.cs new file mode 100644 index 0000000..d67b5bb --- /dev/null +++ b/docs/snippets/text-style/decoration-styles.cs @@ -0,0 +1,16 @@ +.Text(text => +{ + text.Span("Moreover, the decoration can be "); + + text.Span("solid").FontColor(Colors.Indigo.Medium).Underline().DecorationSolid(); + text.Span(", "); + text.Span("double").FontColor(Colors.Blue.Medium).Underline().DecorationDouble(); + text.Span(", "); + text.Span("wavy").FontColor(Colors.LightBlue.Medium).Underline().DecorationWavy(); + text.Span(", "); + text.Span("dotted").FontColor(Colors.Cyan.Medium).Underline().DecorationDotted(); + text.Span(" or "); + text.Span("dashed").FontColor(Colors.Green.Medium) + .Underline().DecorationDashed(); + text.Span("."); +}); diff --git a/docs/snippets/text-style/decoration-styling.cs b/docs/snippets/text-style/decoration-styling.cs new file mode 100644 index 0000000..d9e42fa --- /dev/null +++ b/docs/snippets/text-style/decoration-styling.cs @@ -0,0 +1,12 @@ +.Text(text => +{ + text.Span("This text contains a "); + + text.Span("seriuos") + .Underline() + .DecorationWavy() + .DecorationColor(Colors.Red.Medium) + .DecorationThickness(2); + + text.Span(" typo."); +}); diff --git a/docs/snippets/text-style/font-color.cs b/docs/snippets/text-style/font-color.cs new file mode 100644 index 0000000..5364856 --- /dev/null +++ b/docs/snippets/text-style/font-color.cs @@ -0,0 +1,10 @@ +.Text(text => +{ + text.Span("Each pixel consists of three sub-pixels: "); + text.Span("red").FontColor(Colors.Red.Medium); + text.Span(", "); + text.Span("green").FontColor(Colors.Green.Medium); + text.Span(" and "); + text.Span("blue").FontColor(Colors.Blue.Medium); + text.Span("."); +}); diff --git a/docs/snippets/text-style/font-fallback-emoji.cs b/docs/snippets/text-style/font-fallback-emoji.cs new file mode 100644 index 0000000..d1387df --- /dev/null +++ b/docs/snippets/text-style/font-fallback-emoji.cs @@ -0,0 +1,3 @@ +container + .Text("Popular emojis include 😊, 😂, ❤️, 👍, and 😎.") + .FontFamily("Lato", "Noto Emoji"); diff --git a/docs/snippets/text-style/font-fallback.cs b/docs/snippets/text-style/font-fallback.cs new file mode 100644 index 0000000..7bf161f --- /dev/null +++ b/docs/snippets/text-style/font-fallback.cs @@ -0,0 +1,3 @@ +container + .Text("The Arabic word for programming is البرمجة.") + .FontFamily("Lato", "Noto Sans Arabic"); diff --git a/docs/snippets/text-style/font-family.cs b/docs/snippets/text-style/font-family.cs new file mode 100644 index 0000000..dbad7a7 --- /dev/null +++ b/docs/snippets/text-style/font-family.cs @@ -0,0 +1,12 @@ +.Column(column => +{ + column.Spacing(10); + + column.Item().Text("This is text with default font (Lato)"); + + column.Item().Text("This is text with Noto Serif font") + .FontFamily("Noto Serif"); + + column.Item().Text("This is text with JetBrains Mono font") + .FontFamily("JetBrains Mono"); +}); diff --git a/docs/snippets/text-style/font-features.cs b/docs/snippets/text-style/font-features.cs new file mode 100644 index 0000000..3d9a794 --- /dev/null +++ b/docs/snippets/text-style/font-features.cs @@ -0,0 +1,29 @@ +.Row(row => +{ + row.Spacing(25); + + row.RelativeItem() + .Background(Colors.Grey.Lighten3) + .Padding(10) + .Column(column => + { + column.Item().Text("Without ligatures").FontSize(16); + + column.Item() + .Text("fly and fight") + .FontSize(32) + .DisableFontFeature(FontFeatures.StandardLigatures); + }); + + row.RelativeItem() + .Background(Colors.Grey.Lighten3) + .Padding(10) + .Column(column => + { + column.Item().Text("With ligatures").FontSize(16); + + column.Item().Text("fly and fight") + .FontSize(32) + .EnableFontFeature(FontFeatures.StandardLigatures); + }); +}); diff --git a/docs/snippets/text-style/font-size.cs b/docs/snippets/text-style/font-size.cs new file mode 100644 index 0000000..4ec0579 --- /dev/null +++ b/docs/snippets/text-style/font-size.cs @@ -0,0 +1,16 @@ +.Column(column => +{ + column.Spacing(10); + + column.Item() + .Text("This is small text (16pt)") + .FontSize(16); + + column.Item() + .Text("This is medium text (24pt)") + .FontSize(24); + + column.Item() + .Text("This is large text (36pt)") + .FontSize(36); +}); diff --git a/docs/snippets/text-style/font-weight.cs b/docs/snippets/text-style/font-weight.cs new file mode 100644 index 0000000..4b0b118 --- /dev/null +++ b/docs/snippets/text-style/font-weight.cs @@ -0,0 +1,12 @@ +.Text(text => +{ + text.Span("This sentence demonstrates "); + text.Span("bold").Bold(); + text.Span(", "); + text.Span("normal").NormalWeight(); + text.Span(", "); + text.Span("light").Light(); + text.Span(" and "); + text.Span("thin").Thin(); + text.Span(" font weights."); +}); diff --git a/docs/snippets/text-style/hyphenation.cs b/docs/snippets/text-style/hyphenation.cs new file mode 100644 index 0000000..54ab7da --- /dev/null +++ b/docs/snippets/text-style/hyphenation.cs @@ -0,0 +1,14 @@ +.Column(column => +{ + column.Spacing(20); + + column.Item() + .Background(Colors.Grey.Lighten3) + .Text("Bitte aktualisieren Sie die Zugriffsberechtigungen in der Serverkonfigurationsdatei."); + + column.Item() + .Background(Colors.Grey.Lighten3) + .Text("Bit\u00ADte ak\u00ADtua\u00ADli\u00ADsie\u00ADren Sie die " + + "Zu\u00ADgriffs\u00ADbe\u00ADrech\u00ADti\u00ADgun\u00ADgen in der " + + "Ser\u00ADver\u00ADkon\u00ADfi\u00ADgu\u00ADra\u00ADti\u00ADons\u00ADda\u00ADtei."); +}); diff --git a/docs/snippets/text-style/italic.cs b/docs/snippets/text-style/italic.cs new file mode 100644 index 0000000..6917180 --- /dev/null +++ b/docs/snippets/text-style/italic.cs @@ -0,0 +1,6 @@ +.Text(text => +{ + text.Span("In this sentence, the word "); + text.Span("important").Italic(); + text.Span(" is emphasized using italics."); +}); diff --git a/docs/snippets/text-style/letter-spacing.cs b/docs/snippets/text-style/letter-spacing.cs new file mode 100644 index 0000000..54ba049 --- /dev/null +++ b/docs/snippets/text-style/letter-spacing.cs @@ -0,0 +1,18 @@ +.Column(column => +{ + column.Spacing(20); + + var letterSpacing = new[] { -0.08f, 0f, 0.2f }; + var paragraph = "Letter spacing changes the space between characters."; + + foreach (var spacing in letterSpacing) + { + column + .Item() + .Background(Colors.Grey.Lighten3) + .Padding(5) + .Text(paragraph) + .FontSize(18) + .LetterSpacing(spacing); + } +}); diff --git a/docs/snippets/text-style/line-height.cs b/docs/snippets/text-style/line-height.cs new file mode 100644 index 0000000..8dc6c85 --- /dev/null +++ b/docs/snippets/text-style/line-height.cs @@ -0,0 +1,18 @@ +.Column(column => +{ + column.Spacing(20); + + float[] lineHeights = [0.75f, 1f, 2f]; + var paragraph = "Line height is the vertical distance between lines of text. Tight lines save space, while generous spacing makes long paragraphs easier to follow."; + + foreach (var lineHeight in lineHeights) + { + column + .Item() + .Background(Colors.Grey.Lighten3) + .Padding(5) + .Text(paragraph) + .FontSize(16) + .LineHeight(lineHeight); + } +}); diff --git a/docs/snippets/text-style/subscript.cs b/docs/snippets/text-style/subscript.cs new file mode 100644 index 0000000..60f562d --- /dev/null +++ b/docs/snippets/text-style/subscript.cs @@ -0,0 +1,6 @@ +.Text(text => +{ + text.Span("H"); + text.Span("2").Subscript(); + text.Span("O is the chemical formula for water."); +}); diff --git a/docs/snippets/text-style/superscript.cs b/docs/snippets/text-style/superscript.cs new file mode 100644 index 0000000..2569354 --- /dev/null +++ b/docs/snippets/text-style/superscript.cs @@ -0,0 +1,6 @@ +.Text(text => +{ + text.Span("E = mc"); + text.Span("2").Superscript(); + text.Span(" is the equation of mass-energy equivalence."); +}); diff --git a/docs/snippets/text-style/word-spacing.cs b/docs/snippets/text-style/word-spacing.cs new file mode 100644 index 0000000..db65c0d --- /dev/null +++ b/docs/snippets/text-style/word-spacing.cs @@ -0,0 +1,17 @@ +.Column(column => +{ + column.Spacing(20); + + var wordSpacing = new[] { -0.2f, 0f, 0.4f }; + var paragraph = "Word spacing changes the space between words."; + + foreach (var spacing in wordSpacing) + { + column.Item() + .Background(Colors.Grey.Lighten3) + .Padding(5) + .Text(paragraph) + .FontSize(16) + .WordSpacing(spacing); + } +}); diff --git a/docs/snippets/text/basic.cs b/docs/snippets/text/basic.cs new file mode 100644 index 0000000..0846ba7 --- /dev/null +++ b/docs/snippets/text/basic.cs @@ -0,0 +1,2 @@ +container + .Text("Sample text"); diff --git a/docs/snippets/text/customization.cs b/docs/snippets/text/customization.cs new file mode 100644 index 0000000..1c317c6 --- /dev/null +++ b/docs/snippets/text/customization.cs @@ -0,0 +1,24 @@ +.Column(column => +{ + column.Spacing(10); + + column.Item() + .Element(CellStyle) + .Text("Text with blue color") + .FontColor(Colors.Blue.Darken1); + + column.Item() + .Element(CellStyle) + .Text("Bold and underlined text") + .Bold() + .Underline(); + + column.Item() + .Element(CellStyle) + .Text("Centered small text") + .FontSize(12) + .AlignCenter(); + + static IContainer CellStyle(IContainer container) => + container.Background(Colors.Grey.Lighten3).Padding(10); +}); diff --git a/docs/snippets/text/hyperlink.cs b/docs/snippets/text/hyperlink.cs new file mode 100644 index 0000000..379edbe --- /dev/null +++ b/docs/snippets/text/hyperlink.cs @@ -0,0 +1,14 @@ +.Text(text => +{ + var hyperlinkStyle = TextStyle.Default + .FontColor(Colors.Blue.Medium) + .Underline(); + + text.Span("To learn more about QuestPDF, please visit its "); + text.Hyperlink("homepage", "https://www.questpdf.com/").Style(hyperlinkStyle); + text.Span(", "); + text.Hyperlink("GitHub repository", "https://github.com/QuestPDF/QuestPDF").Style(hyperlinkStyle); + text.Span(" and "); + text.Hyperlink("NuGet package page", "https://www.nuget.org/packages/QuestPDF").Style(hyperlinkStyle); + text.Span("."); +}); diff --git a/docs/snippets/text/rich.cs b/docs/snippets/text/rich.cs new file mode 100644 index 0000000..beaf28d --- /dev/null +++ b/docs/snippets/text/rich.cs @@ -0,0 +1,15 @@ +container + .Text(text => + { + text.AlignCenter(); + + text.Span("The "); + text.Span("chemical formula").Underline(); + text.Span(" of "); + text.Span("sulfuric acid").BackgroundColor(Colors.Amber.Lighten3); + text.Span(" is H"); + text.Span("2").Subscript(); + text.Span("SO"); + text.Span("4").Subscript(); + text.Span("."); + });