Skip to content

QuantumForge is a lightweight NuGet package for effortless generation of PDFs and XPS documents from enumerables, DataGridViews in Windows Forms, and DataGrids in WPF. Customize column settings using attributes, and enjoy features like getting byte arrays, saving to file paths, and direct display in the browser.

Notifications You must be signed in to change notification settings

DhurghamFahem/QuantumFroge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 

Repository files navigation

QuantumFroge

QuantumFrogePDF is a versatile NuGet package designed for easy generation of PDFs and XPS documents from enumerables, DataGridViews in Windows Forms, and DataGrids in WPF. It provides customization options for column settings using attributes, allowing users to get a byte array, save to a file path, and even display the generated PDF in the browser.

Installation

You can install QuantumFroge using the NuGet Package Manager:

dotnet add package QuantumFroge

Features

  • Generate PDFs from enumerables.
  • Generate PDFs from DataGridViews in Windows Forms.
  • Generate PDFs from DataGrids in WPF.
  • Generate XPS from enumerables.
  • Generate XPS from DataGridViews in Windows Forms.
  • Generate XPS from DataGrids in WPF.
  • Customize column settings using attributes.
  • Include headers and footers with flexible font families and colors in the generated PDF.
  • Get a byte array of the generated document.
  • Save the document to a specified file path.
  • Save the document to a Stream.
  • Display the generated PDF directly in the browser.

Usage

Customization Options

  • Customize the Class columns
public class AccountModel // Test class 
{
    [QuantumForgeName(displayName: "Account number")] // To display the attribute value in the generated document.
    public int Id { get; set; }
    [QuantumForgeName(displayName: "Account name")]
    [QuantumForgeWidth(width: 200)] // To set the column width in the generated document.
    public string Name { get; set; } = "";
    public string Phone { get; set; } = "";
    public DateTime Birthdate { get; set; }
    [QuantumForgeCanSum] // If the column is numeric you can set QuantumForgeCanSum to display the summation of the column in the table footer.
    [QuantumForgeSummationText(summationText: "Balance", reverse: true)] // You can change the summation text to any thing.
    public decimal Balance { get; set; }
    [QuantumForgeIgnore] // To ignore the columns to be generated in the document.
    public bool Active { get; set; }
}
  • Customize Header and Footer
var accounts = InvoiceDataSource.GetAccounts();

var settings = new QuantumForgePageSettings
{
    Background = "#739072"
};

settings.Header.Value = "Test company header";
settings.Header.Settings = new()
{
    Background = "#3A4D39",
    TextStyle = TextStyle.Default.FontColor("#ECE3CE")
                                  .FontSize(18)
};
settings.Header.Height = 50;

settings.TableHeader = new()
{
    Background = "#4F6F52",
    TextStyle = TextStyle.Default.FontColor("#ECE3CE")
                                 .FontSize(14)
};

settings.TableContent.Background = "#739072";
settings.TableContent.TextStyle = TextStyle.Default.FontColor("#ECE3CE");

settings.TableFooter.Background = "#739072";
settings.TableFooter.TextStyle = TextStyle.Default.FontColor("#ECE3CE");

settings.Footer.Value = "Test company footer";
settings.Footer.Settings = new()
{
    Background = "#3A4D39",
    TextStyle = TextStyle.Default.FontColor("#ECE3CE")
                                 .FontSize(10)
};
QuantumForgeService.GeneratePdfAndShow<AccountModel>(accounts, settings);

Getting Byte Array

  • Getting Byte Array from Enumerables
var accounts = InvoiceDataSource.GetAccounts();
var bytes = QuantumForgeService.GeneratePdf<AccountModel>(accounts);
  • Getting Byte Array DataGridViews (Windows Forms)
var bytes = QuantumForgeService.GeneratePdf<AccountModel>(dataGridView1.DataSource);
  • Getting Byte Array DataGrids (WPF)
var bytes = QuantumForgeService.GeneratePdf<AccountModel>(dataGrid.ItemsSource);

Saving to File Path

  • Saving to File Path from Enumerables
var filePath = "[YOUR PATH]";
var accounts = InvoiceDataSource.GetAccounts();
QuantumForgeService.GeneratePdf<AccountModel>(accounts, filePath);
  • Saving to File Path DataGridViews (Windows Forms)
var filePath = "[YOUR PATH]";
QuantumForgeService.GeneratePdf<AccountModel>(dataGridView1.DataSource, filePath);
  • Saving to File Path DataGrids (WPF)
var filePath = "[YOUR PATH]";
QuantumForgeService.GeneratePdf<AccountModel>(dataGrid.ItemsSource, filePath);

Saving to Stream

  • Saving to Stream Path from Enumerables
var accounts = InvoiceDataSource.GetAccounts();
using var stream = new MemoryStream();
QuantumForgeService.GeneratePdf<AccountModel>(accounts, stream);
  • Saving to Stream Path DataGridViews (Windows Forms)
using var stream = new MemoryStream();
QuantumForgeService.GeneratePdf<AccountModel>(dataGridView1.DataSource, stream);
  • Saving to Stream Path DataGrids (WPF)
using var stream = new MemoryStream();
QuantumForgeService.GeneratePdf<AccountModel>(dataGrid.ItemsSource, stream);

Displaying generated document

  • Displaying generated document from Enumerables
QuantumForgeService.GeneratePdfAndShow<AccountModel>(accounts);
  • Displaying generated document DataGridViews (Windows Forms)
QuantumForgeService.GeneratePdfAndShow<AccountModel>(dataGridView1.DataSource);
  • Displaying generated document DataGrids (WPF)
QuantumForgeService.GeneratePdfAndShow<AccountModel>(dataGrid.ItemsSource);

License

  • This project is licensed under the MIT License.

About

QuantumForge is a lightweight NuGet package for effortless generation of PDFs and XPS documents from enumerables, DataGridViews in Windows Forms, and DataGrids in WPF. Customize column settings using attributes, and enjoy features like getting byte arrays, saving to file paths, and direct display in the browser.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages