diff --git a/QuestPDF.Examples/DefaultTextStyleExample.cs b/QuestPDF.Examples/DefaultTextStyleExample.cs
index 9efce3f..97f638b 100644
--- a/QuestPDF.Examples/DefaultTextStyleExample.cs
+++ b/QuestPDF.Examples/DefaultTextStyleExample.cs
@@ -24,7 +24,7 @@ namespace QuestPDF.Examples
page.Margin(20);
page.Size(PageSizes.A4);
- page.Background(Colors.White);
+ page.PageColor(Colors.White);
page.Content().Column(column =>
{
diff --git a/QuestPDF.Examples/DifferentHeaderOnFirstPageExample.cs b/QuestPDF.Examples/DifferentHeaderOnFirstPageExample.cs
index 4c2b733..c438d20 100644
--- a/QuestPDF.Examples/DifferentHeaderOnFirstPageExample.cs
+++ b/QuestPDF.Examples/DifferentHeaderOnFirstPageExample.cs
@@ -24,7 +24,7 @@ namespace QuestPDF.Examples
{
page.Size(PageSizes.A6);
page.Margin(5);
- page.Background(Colors.White);
+ page.PageColor(Colors.White);
page.Header().Column(column =>
{
diff --git a/QuestPDF.Examples/EnsureSpaceExample.cs b/QuestPDF.Examples/EnsureSpaceExample.cs
index 27de8ad..e448d61 100644
--- a/QuestPDF.Examples/EnsureSpaceExample.cs
+++ b/QuestPDF.Examples/EnsureSpaceExample.cs
@@ -21,7 +21,7 @@ namespace QuestPDF.Examples
{
page.Margin(20);
page.Size(PageSizes.A7.Landscape());
- page.Background(Colors.White);
+ page.PageColor(Colors.White);
page.Header().Text("With ensure space").SemiBold();
diff --git a/QuestPDF.Examples/MinimalApiExamples.cs b/QuestPDF.Examples/MinimalApiExamples.cs
index 4d7e3ba..c58c9cd 100644
--- a/QuestPDF.Examples/MinimalApiExamples.cs
+++ b/QuestPDF.Examples/MinimalApiExamples.cs
@@ -19,11 +19,12 @@ namespace QuestPDF.Examples
{
page.Size(PageSizes.A4);
page.Margin(2, Unit.Centimetre);
- page.Background(Colors.White);
- page.DefaultTextStyle(TextStyle.Default.Size(20));
+ page.PageColor(Colors.White);
+ page.DefaultTextStyle(x => x.FontSize(20));
page.Header()
- .Text("Hello PDF!").SemiBold().FontSize(36).FontColor(Colors.Blue.Medium);
+ .Text("Hello PDF!")
+ .SemiBold().FontSize(36).FontColor(Colors.Blue.Medium);
page.Content()
.PaddingVertical(1, Unit.Centimetre)
@@ -48,48 +49,5 @@ namespace QuestPDF.Examples
Process.Start("explorer.exe", "hello.pdf");
}
-
- [Test]
- public void MinimalApi2()
- {
- RenderingTest
- .Create()
- .ProduceImages()
- .ShowResults()
- .RenderDocument(container =>
- {
- container.Page(page =>
- {
- page.Size(PageSizes.A4);
- page.Margin(2, Unit.Centimetre);
- page.Background(Colors.White);
- page.DefaultTextStyle(TextStyle.Default.Size(20));
-
- page.Header()
- .Text("Hello PDF!")
- .SemiBold()
- .FontSize(36)
- .FontColor(Colors.Blue.Medium);
-
- page.Content()
- .PaddingVertical(1, Unit.Centimetre)
- .Column(x =>
- {
- x.Spacing(20);
-
- x.Item().Text(Placeholders.LoremIpsum());
- x.Item().Image(Placeholders.Image(200, 100));
- });
-
- page.Footer()
- .AlignCenter()
- .Text(x =>
- {
- x.Span("Page ");
- x.CurrentPageNumber();
- });
- });
- });
- }
}
}
\ No newline at end of file
diff --git a/QuestPDF.Examples/PageBackgroundForeground.cs b/QuestPDF.Examples/PageBackgroundForegroundExample.cs
similarity index 59%
rename from QuestPDF.Examples/PageBackgroundForeground.cs
rename to QuestPDF.Examples/PageBackgroundForegroundExample.cs
index 23a3fd0..1255d55 100644
--- a/QuestPDF.Examples/PageBackgroundForeground.cs
+++ b/QuestPDF.Examples/PageBackgroundForegroundExample.cs
@@ -8,15 +8,15 @@ using QuestPDF.Infrastructure;
namespace QuestPDF.Examples
{
- public class PageBackgroundForeground
+ public class PageBackgroundForegroundExample
{
[Test]
- public void Test()
+ public void PageBackgroundForeground()
{
RenderingTest
.Create()
- .PageSize(550, 400)
- .ProducePdf()
+ .ProduceImages()
+ .MaxPages(100)
.ShowResults()
.RenderDocument(document =>
{
@@ -25,15 +25,23 @@ namespace QuestPDF.Examples
page.Size(PageSizes.A4);
page.Margin(1, Unit.Inch);
page.DefaultTextStyle(TextStyle.Default.FontSize(16));
+ page.PageColor(Colors.White);
- page.Foreground()
- .AlignMiddle()
- .AlignCenter()
- .Text("Watermark")
- .FontSize(64)
- .FontColor(Colors.Blue.Lighten3);
+ const string transparentBlue = "#662196f3";
+
+ page.Background()
+ .AlignTop()
+ .ExtendHorizontal()
+ .Height(200)
+ .Background(transparentBlue);
- page.Header().Text("Background and foreground").Bold().FontColor(Colors.Blue.Medium).FontSize(24);
+ page.Foreground()
+ .AlignBottom()
+ .ExtendHorizontal()
+ .Height(250)
+ .Background(transparentBlue);
+
+ page.Header().Text("Background and foreground").Bold().FontColor(Colors.Blue.Darken2).FontSize(36);
page.Content().PaddingVertical(25).Column(column =>
{
diff --git a/QuestPDF.Examples/ShowOnceExample.cs b/QuestPDF.Examples/ShowOnceExample.cs
index 2fa5f29..54e182b 100644
--- a/QuestPDF.Examples/ShowOnceExample.cs
+++ b/QuestPDF.Examples/ShowOnceExample.cs
@@ -21,7 +21,7 @@ namespace QuestPDF.Examples
{
page.Margin(20);
page.Size(PageSizes.A7.Landscape());
- page.Background(Colors.White);
+ page.PageColor(Colors.White);
page.Header().Text("With show once").SemiBold();
diff --git a/QuestPDF.Examples/SkipOnceExample.cs b/QuestPDF.Examples/SkipOnceExample.cs
index 182a65e..4a56b62 100644
--- a/QuestPDF.Examples/SkipOnceExample.cs
+++ b/QuestPDF.Examples/SkipOnceExample.cs
@@ -21,7 +21,7 @@ namespace QuestPDF.Examples
{
page.Margin(20);
page.Size(PageSizes.A7.Landscape());
- page.Background(Colors.White);
+ page.PageColor(Colors.White);
page.Header().Column(column =>
{
diff --git a/QuestPDF.Examples/TextExamples.cs b/QuestPDF.Examples/TextExamples.cs
index 3ad513f..0382416 100644
--- a/QuestPDF.Examples/TextExamples.cs
+++ b/QuestPDF.Examples/TextExamples.cs
@@ -82,7 +82,7 @@ namespace QuestPDF.Examples
.Padding(10)
.Text(text =>
{
- text.DefaultTextStyle(TextStyle.Default.Size(20));
+ text.DefaultTextStyle(TextStyle.Default.FontSize(20));
text.Span("This is a random image aligned to the baseline: ");
text.Element()
@@ -239,7 +239,7 @@ namespace QuestPDF.Examples
.Padding(10)
.Text(text =>
{
- text.DefaultTextStyle(TextStyle.Default);
+ text.DefaultTextStyle(TextStyle.Default.FontSize(20));
text.AlignLeft();
text.ParagraphSpacing(10);
@@ -285,7 +285,7 @@ namespace QuestPDF.Examples
container.Page(page =>
{
page.Margin(50);
- page.Background(Colors.White);
+ page.PageColor(Colors.White);
page.Size(PageSizes.A4);
@@ -308,7 +308,7 @@ namespace QuestPDF.Examples
container.Page(page =>
{
page.Margin(50);
- page.Background(Colors.White);
+ page.PageColor(Colors.White);
page.Size(PageSizes.A4);
@@ -331,7 +331,7 @@ namespace QuestPDF.Examples
container.Page(page =>
{
page.Margin(50);
- page.Background(Colors.White);
+ page.PageColor(Colors.White);
page.Size(PageSizes.A4);
diff --git a/QuestPDF/Elements/Page.cs b/QuestPDF/Elements/Page.cs
index be8e678..275d876 100644
--- a/QuestPDF/Elements/Page.cs
+++ b/QuestPDF/Elements/Page.cs
@@ -30,6 +30,7 @@ namespace QuestPDF.Elements
public void Compose(IContainer container)
{
container
+ .Background(BackgroundColor)
.Layers(layers =>
{
layers
@@ -44,9 +45,7 @@ namespace QuestPDF.Elements
.MaxWidth(MaxSize.Width)
.MaxHeight(MaxSize.Height)
-
- .Background(BackgroundColor)
-
+
.PaddingLeft(MarginLeft)
.PaddingRight(MarginRight)
.PaddingTop(MarginTop)
diff --git a/QuestPDF/Fluent/PageExtensions.cs b/QuestPDF/Fluent/PageExtensions.cs
index e043ed3..98d2b73 100644
--- a/QuestPDF/Fluent/PageExtensions.cs
+++ b/QuestPDF/Fluent/PageExtensions.cs
@@ -88,11 +88,17 @@ namespace QuestPDF.Fluent
DefaultTextStyle(handler(TextStyle.Default));
}
- public void Background(string color)
+ public void PageColor(string color)
{
Page.BackgroundColor = color;
}
+ [Obsolete("This element has been renamed since version 2022.3. Please use the PageColor method.")]
+ public void Background(string color)
+ {
+ PageColor(color);
+ }
+
public IContainer Background()
{
var container = new Container();
diff --git a/QuestPDF/Fluent/TextStyleExtensions.cs b/QuestPDF/Fluent/TextStyleExtensions.cs
index a748225..94e4351 100644
--- a/QuestPDF/Fluent/TextStyleExtensions.cs
+++ b/QuestPDF/Fluent/TextStyleExtensions.cs
@@ -1,4 +1,5 @@
using System;
+using System.ComponentModel;
using QuestPDF.Infrastructure;
namespace QuestPDF.Fluent
diff --git a/readme.md b/readme.md
index d555e7e..b502ce9 100644
--- a/readme.md
+++ b/readme.md
@@ -4,6 +4,7 @@
---
+[](https://www.nuget.org/packages/QuestPDF/)
[](https://github.com/QuestPDF/QuestPDF/stargazers)
[](https://www.nuget.org/packages/QuestPDF/)
[](https://www.nuget.org/packages/QuestPDF/)
@@ -19,13 +20,28 @@ I have designed this layouting engine with full paging support in mind. The docu
All great frameworks and libraries started from zero. Please help me make QuestPDF a commonly known library and an obvious choice for generating PDF documents.
- ⭐ Give this repository a star,
-- 💬 Share it with your team members.
+- 💬 Share it with your team members,
+- ❤ Please consider supporting
+
+## Share
+
+// consider removing logos
+
+[](https://reddit.com/submit?url=https://github.com/QuestPDF/QuestPDF&title=QuestPDF)
+
+[](https://news.ycombinator.com/submitlink?u=https://github.com/QuestPDF/QuestPDF)
+
+[](https://twitter.com/share?url=https://github.com/QuestPDF/QuestPDF&t=QuestPDF)
+
+[](https://www.facebook.com/sharer/sharer.php?u=https://github.com/QuestPDF/QuestPDF)
+
+[](https://www.linkedin.com/shareArticle?url=https://github.com/QuestPDF/QuestPDF&title=QuestPDF)
## Installation
The library is available as a nuget package. You can install it as any other nuget package from your IDE, try to search by `QuestPDF`. You can find package details [on this webpage](https://www.nuget.org/packages/QuestPDF/).
-```c#
+```xml
// Package Manager
Install-Package QuestPDF
@@ -33,11 +49,23 @@ Install-Package QuestPDF
dotnet add package QuestPDF
// Package reference in .csproj file
-
+
```
## Documentation
+[](https://www.linkedin.com/shareArticle?url=https://github.com/QuestPDF/QuestPDF&title=QuestPDF)
+A short and easy to follow tutorial showing how to design an invoice document under 200 lines of code.
+
+
+[](https://www.linkedin.com/shareArticle?url=https://github.com/QuestPDF/QuestPDF&title=QuestPDF)
+A detailed description of behavior of all available components and how to use them with C# Fluent API.
+
+
+[](https://www.linkedin.com/shareArticle?url=https://github.com/QuestPDF/QuestPDF&title=QuestPDF)
+Everything that may help you designing great reports and create reusable code that is easy to maintain.
+
+
**[🚀 Getting started tutorial](https://www.questpdf.com/documentation/getting-started.html)** - a short and easy to follow tutorial showing how to design an invoice document under 200 lines of code.
**[📖 API Reference](https://www.questpdf.com/documentation/api-reference.html)** - a detailed description of behavior of all available components and how to use them with C# Fluent API.
@@ -61,10 +89,11 @@ Document.Create(container =>
page.Size(PageSizes.A4);
page.Margin(2, Unit.Centimetre);
page.Background(Colors.White);
- page.DefaultTextStyle(TextStyle.Default.Size(20));
+ page.DefaultTextStyle(x => x.FontSize(20));
page.Header()
- .Text("Hello PDF!", TextStyle.Default.SemiBold().Size(36).Color(Colors.Blue.Medium));
+ .Text("Hello PDF!")
+ .SemiBold().FontSize(36).FontColor(Colors.Blue.Medium);
page.Content()
.PaddingVertical(1, Unit.Centimetre)