Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

<img src="./docs/img/example-hello-pdf.png" width="400" alt="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).
Binary file added docs/img/example-hello-pdf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading