diff --git a/README.md b/README.md index 80d178c57..54a8bb015 100644 --- a/README.md +++ b/README.md @@ -33,3 +33,64 @@ ShinyPDF is a modern open-source .NET library for PDF document generation. Offer ## Let's get started Begin exploring the ShinyPDF library today. + +Install the [NuGet package](https://www.nuget.org/packages/ShinyPDF): + +```bash +dotnet add package ShinyPDF +``` + +On Linux, also add the native assets for SkiaSharp and HarfBuzzSharp: + +```bash +dotnet add package SkiaSharp.NativeAssets.Linux +dotnet add package HarfBuzzSharp.NativeAssets.Linux +``` + +Then describe your document with the Fluent API and generate the PDF: + +```csharp +using ShinyPDF.Fluent; +using ShinyPDF.Helpers; +using ShinyPDF.Infrastructure; + +Document.Create(container => +{ + container.Page(page => + { + page.Size(PageSizes.A4); + page.Margin(2, Unit.Centimetre); + page.PageColor(Colors.White); + page.DefaultTextStyle(x => x.FontSize(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(); + }); + }); +}) +.GeneratePdf("hello.pdf"); +``` + +The result: + +Generated PDF page with a blue 'Hello PDF!' heading, a paragraph of placeholder text, a gradient placeholder image and a 'Page 1' footer + +`Placeholders` generates sample text and images, which is handy while designing a layout. More examples are in [src/ShinyPDF.Examples](src/ShinyPDF.Examples). diff --git a/docs/img/example-hello-pdf.png b/docs/img/example-hello-pdf.png new file mode 100644 index 000000000..ad36dd309 Binary files /dev/null and b/docs/img/example-hello-pdf.png differ