QuestPDF.Pieces 1.1.1

dotnet add package QuestPDF.Pieces --version 1.1.1
                    
NuGet\Install-Package QuestPDF.Pieces -Version 1.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="QuestPDF.Pieces" Version="1.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="QuestPDF.Pieces" Version="1.1.1" />
                    
Directory.Packages.props
<PackageReference Include="QuestPDF.Pieces" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add QuestPDF.Pieces --version 1.1.1
                    
#r "nuget: QuestPDF.Pieces, 1.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=QuestPDF.Pieces&version=1.1.1
                    
Install QuestPDF.Pieces as a Cake Addin
#tool nuget:?package=QuestPDF.Pieces&version=1.1.1
                    
Install QuestPDF.Pieces as a Cake Tool

๐Ÿ“„ QuestPDF.Pieces

Composable, reusable building blocks for creating professional PDF documents using QuestPDF.

Build dynamic, high-quality PDFs with a modular and component-based approach.


๐Ÿš€ Overview

QuestPDF.Pieces is a robust and flexible framework built on top of QuestPDF. It simplifies PDF generation by introducing reusable "pieces" (components) that encapsulate layout logic, enabling developers to create clean, maintainable, and modular code.

Whether you're generating invoices, reports, proposals, forms, or other documents, this library provides a structured and intuitive way to design your documents.


โœจ Key Features

  • Abstract Base Classes: Simplify the creation of structured PDF sections and components.
  • Reusable Components: Build headers, footers, tables, and other elements with ease.
  • Seamless Integration: Works effortlessly with QuestPDFโ€™s fluent API.
  • Clean Architecture: Promotes modular and maintainable code for PDF generation.
  • Developer-Friendly: Extensible, easy to test, and designed for productivity.

๐Ÿ“– Basic Usage

Hereโ€™s an example of how to use QuestPDF.Pieces to create a simple PDF document:

// filepath: ExampleUsage.cs
using QuestPDF.Pieces;
using QuestPDF.Pieces.Components;
using QuestPDF.Pieces.Document;
using QuestPDF.Pieces.Sections;

var documentComposer = new DocumentComposer();

// Add a header section
var header = new HeaderSection();
header.AddComponent(new TextLine("Header Title", size: 16));
documentComposer.AddComponent(header);

// Add a body section
var body = new BodySection();
body.AddComponent(new TextLine("This is the body content."));
body.AddComponent(new Seperator());
body.AddComponent(new TextLine("More content here."));
documentComposer.AddComponent(body);

// Add a footer section
var footer = new FooterSection();
footer.AddComponent(new TextLine("Footer Content", size: 10));
documentComposer.AddComponent(footer);

// Generate the PDF document
var document = documentComposer.Compose();
document.GeneratePdf("output.pdf");

This example demonstrates how to create a document with a header, body, and footer using reusable components like TextLine and Seperator.


๐Ÿ› ๏ธ Extensibility

Creating Custom Components

You can easily create new components by extending the BasePiece class within the QuestPDF.Pieces.Components namespace. For example:

using QuestPDF.Pieces.Components;
using QuestPDF.Fluent;

public class CustomTextLine(string text, int size = 12) : BasePiece
{
    public override string ElementName { get; } = "CustomTextLine";

    public override void Compose(ColumnDescriptor x)
    {
        x.Item().Text(text).FontSize(size).Bold();
    }
}

This allows you to define custom behavior and styling for your components.

Overriding Sections

You can override existing sections like HeaderSection, BodySection, or FooterSection to provide default behavior or styling. For example:

using QuestPDF.Pieces.Sections;
using QuestPDF.Pieces.Components;

public class DefaultHeaderSection : HeaderSection
{
    public DefaultHeaderSection()
    {
        AddComponent(new TextLine("Default Header", size: 18));
    }
}

This enables you to standardize headers, footers, or other sections across your documents.


๐Ÿ“œ License

This project is licensed under the MIT License. See the LICENSE file for more details.


๐Ÿค Contributing

Contributions are welcome! If you have ideas for improvements or new features, feel free to open an issue or submit a pull request. Please ensure your contributions align with the project's goals and coding standards.


๐Ÿ“ง Contact

For questions, feedback, or support, please reach out via the GitHub repository.


Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.1 139 4/21/2025
1.0.8 94 4/19/2025
1.0.7 79 4/19/2025
1.0.6 100 4/19/2025
1.0.5 76 4/19/2025
1.0.4 94 4/19/2025
1.0.3 73 4/19/2025
1.0.2 74 4/19/2025
1.0.1 75 4/19/2025
1.0.0 77 4/19/2025

Version 1.1.0: release of QuestPDF.Pieces version 1.1.0 with more composable PDF components.
     Version 1.0.0: Introduced the core functionality for composable PDF components.