MyGit

2022.12

QuestPDF/QuestPDF

版本发布时间: 2022-12-14 20:54:35

QuestPDF/QuestPDF最新发布版本:2024.3.2(2024-04-26 03:34:03)

QuestPDF offers a layout engine designed with full paging support in mind. The document consists of many simple elements (e.g. border, background, image, text, padding, table, grid etc.) that are composed together to create more complex structures. This way, as a developer, you can understand the behavior of every element and use them with full confidence. Additionally, the document and all its elements support paging functionality. For example, an element can be moved to the next page (if there is not enough space) or even be split between pages like table's rows.

To learn how easy it is to design documents with the library, let's quickly analyse the code below:

using QuestPDF.Fluent;
using QuestPDF.Helpers;
using QuestPDF.Infrastructure;

// code in your main method
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");

And compare it to the produced PDF file:


Please help by giving a star

⭐ Please consider giving a start to this repository. It takes seconds and helps thousands of developers! ⭐

What's new? 🎊

This QuestPDF release is special as it mainly consists of features proposed and developed by the community:

  1. Feature: implemented LetterSpacing property for the Text element (implemeneted by @Bebo-Maker in #398)

  2. Improvement: the Text element API accepts now only string values, objects are not automatically converted anymore (proposed by @rstm-sf in #362)

  3. Fix: the Alignment element incorrectly limits size of its child when only one axis is set: horizontal or vertical (found by @zlatanov in #401)

  4. Maintenance: Updated SkiaSharp dependency to 2.88.3. Updated Avalonia dependency in the QuestPDF.Previewer project to the latest version. (this was a long awaiting effort that should improve experience for many developers)

  5. Development: Implemented usage on GitHub Actions to trigger automated solution build after every commit. This build is also used for packing nuget artifacts. It is a great starting point for future improvements. (proposed by @rstm-sf in #366)

Let me thank you all for your help!

Letter spacing

Letter spacing allows to increase or decrease space between characters. This setting is useful when you want to make the text more compact (by decreasing letter spacing) or easier to read (by increasing letter spacing):

This settings uses relative units. Example: let's assume your text has font size 20. If letter spacing is set to 0.1, an additional space of 2 points will be added between characters.

.Column(column =>
{
    var letterSpacing = new[] { -0.05f, 0f, 0.2f };
    var paragraph = Placeholders.Sentence();

    foreach (var spacing in letterSpacing)
    {
        column
            .Item()
            .Border(1)
            .Padding(10)
            .Column(nestedColumn =>
            {
                nestedColumn
                    .Item()
                    .Text(paragraph)
                    .FontSize(18)
                    .LetterSpacing(spacing); // <- here 😊

                nestedColumn
                    .Item()
                    .Text($"Letter spacing of {spacing} em")
                    .FontSize(14)
                    .Italic()
                    .FontColor(Colors.Blue.Medium);
            });
        
    }
});

相关地址:原始地址 下载(tar) 下载(zip)

查看:2022-12-14发行的版本