BizzelTech.PdfPro 1.0.0

dotnet add package BizzelTech.PdfPro --version 1.0.0
                    
NuGet\Install-Package BizzelTech.PdfPro -Version 1.0.0
                    
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="BizzelTech.PdfPro" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BizzelTech.PdfPro" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="BizzelTech.PdfPro" />
                    
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 BizzelTech.PdfPro --version 1.0.0
                    
#r "nuget: BizzelTech.PdfPro, 1.0.0"
                    
#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.
#:package BizzelTech.PdfPro@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BizzelTech.PdfPro&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=BizzelTech.PdfPro&version=1.0.0
                    
Install as a Cake Tool

BizzelTech.PdfPro

A comprehensive .NET library for advanced PDF operations including creation, reading, content analysis, and HTML/CSS to PDF conversion. Built for .NET 8, 9, and 10.

Features

PDF Generation

  • HTML to PDF: Convert HTML content to PDF with full CSS support
  • SCSS Compilation: Built-in SASS/SCSS preprocessing for advanced styling
  • Vue.js Templates: Seamless integration with Vue.js template structure
  • Page Configuration: Flexible page sizes, orientations, and margins
  • Metadata Support: Set document properties, creator, title, etc.

PDF Reading & Analysis

  • Text Extraction: Extract text content from PDF documents
  • Image Extraction: Extract embedded images with metadata
  • Content Analysis: Detect text-based vs image-based PDFs
  • Document Information: Access PDF metadata, page count, version info
  • Page-by-Page Processing: Process individual pages for large documents

Advanced Features

  • Multi-format Support: Various input formats (HTML, CSS, SCSS)
  • Fluent API: Easy-to-use builder pattern for complex operations
  • Async Operations: Full async/await support for performance
  • Error Handling: Comprehensive error reporting and validation
  • Logging Integration: Microsoft.Extensions.Logging support

Installation

dotnet add package BizzelTech.PdfPro

Or via Package Manager Console:

Install-Package BizzelTech.PdfPro

Quick Start

Basic HTML to PDF Conversion

using BizzelTech.PdfPro;

// Simple HTML to PDF
var result = await PdfPro.Create()
    .FromHtml("<h1>Hello World</h1><p>This is a PDF!</p>")
    .WithPageSize(PageSize.A4)
    .GeneratePdfAsync();

if (result.IsSuccess)
{
    await File.WriteAllBytesAsync("output.pdf", result.Data);
}

Advanced PDF Generation with SCSS

using BizzelTech.PdfPro;

var html = @"
<!DOCTYPE html>
<html>
<head>
    <title>Advanced Report</title>
</head>
<body>
    <div class='header'>
        <h1>Monthly Report</h1>
        <div class='date'>{{date}}</div>
    </div>
    <div class='content'>
        <div class='metrics'>
            <div class='metric'>
                <span class='label'>Revenue</span>
                <span class='value'>${{revenue}}</span>
            </div>
        </div>
    </div>
</body>
</html>";

var scss = @"
$primary-color: #2c3e50;
$success-color: #27ae60;

.header {
    background: $primary-color;
    color: white;
    padding: 20px;
    margin-bottom: 30px;
    
    h1 {
        margin: 0;
        font-size: 24px;
    }
    
    .date {
        font-size: 14px;
        opacity: 0.8;
    }
}

.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    
    .metric {
        border: 1px solid #ddd;
        padding: 15px;
        border-radius: 5px;
        
        .label {
            display: block;
            font-weight: bold;
            margin-bottom: 5px;
        }
        
        .value {
            font-size: 18px;
            color: $success-color;
        }
    }
}";

var templateData = new Dictionary<string, string>
{
    {"date", DateTime.Now.ToString("MMMM yyyy")},
    {"revenue", "125,000"}
};

var result = await PdfPro.Create()
    .FromHtml(html)
    .WithScss(scss)
    .WithTemplateData(templateData)
    .WithPageSize(PageSize.A4)
    .WithMargins(20, 20, 20, 20)
    .WithMetadata(metadata => metadata
        .SetTitle("Monthly Report")
        .SetAuthor("BizzelTech Systems")
        .SetSubject("Financial Report"))
    .GeneratePdfAsync();

if (result.IsSuccess)
{
    await File.WriteAllBytesAsync("report.pdf", result.Data);
    Console.WriteLine($"PDF generated successfully: {result.Data.Length} bytes");
}

Vue.js Template Integration

using BizzelTech.PdfPro;

// Perfect for Vue.js developers - familiar template syntax
var vueTemplate = @"
<template>
  <div class='invoice'>
    <header class='invoice-header'>
      <h1>Invoice #{{invoiceNumber}}</h1>
      <div class='company-info'>
        <h2>{{companyName}}</h2>
        <p>{{companyAddress}}</p>
      </div>
    </header>
    
    <section class='invoice-details'>
      <div class='bill-to'>
        <h3>Bill To:</h3>
        <p>{{customerName}}</p>
        <p>{{customerAddress}}</p>
      </div>
      
      <div class='invoice-meta'>
        <p><strong>Date:</strong> {{invoiceDate}}</p>
        <p><strong>Due Date:</strong> {{dueDate}}</p>
      </div>
    </section>
    
    <table class='line-items'>
      <thead>
        <tr>
          <th>Description</th>
          <th>Quantity</th>
          <th>Rate</th>
          <th>Amount</th>
        </tr>
      </thead>
      <tbody>
        <tr v-for='item in items' :key='item.id'>
          <td>{{item.description}}</td>
          <td>{{item.quantity}}</td>
          <td>${{item.rate}}</td>
          <td>${{item.amount}}</td>
        </tr>
      </tbody>
      <tfoot>
        <tr>
          <td colspan='3'><strong>Total:</strong></td>
          <td><strong>${{total}}</strong></td>
        </tr>
      </tfoot>
    </table>
  </div>
</template>";

var invoiceData = new
{
    invoiceNumber = "INV-2024-001",
    companyName = "BizzelTech Solutions",
    companyAddress = "123 Tech Street, Innovation City",
    customerName = "Acme Corporation",
    customerAddress = "456 Business Ave, Commerce Town",
    invoiceDate = DateTime.Now.ToString("MM/dd/yyyy"),
    dueDate = DateTime.Now.AddDays(30).ToString("MM/dd/yyyy"),
    items = new[]
    {
        new { id = 1, description = "Web Development", quantity = "40", rate = "150.00", amount = "6,000.00" },
        new { id = 2, description = "Database Setup", quantity = "1", rate = "500.00", amount = "500.00" }
    },
    total = "6,500.00"
};

var result = await PdfPro.Create()
    .FromVueTemplate(vueTemplate)
    .WithTemplateData(invoiceData)
    .WithPageSize(PageSize.A4)
    .WithCss(invoiceCss) // Add your invoice styling
    .GeneratePdfAsync();

PDF Reading and Analysis

using BizzelTech.PdfPro;

// Analyze PDF content
var analysisResult = await PdfPro.Read()
    .FromFile("document.pdf")
    .AnalyzePdfAsync();

if (analysisResult.IsSuccess)
{
    var analysis = analysisResult.Data;
    Console.WriteLine($"Document Type: {analysis.DocumentType}");
    Console.WriteLine($"Has Text: {analysis.HasTextContent}");
    Console.WriteLine($"Has Images: {analysis.HasImages}");
    Console.WriteLine($"Text Coverage: {analysis.TextCoveragePercentage:F1}%");
    Console.WriteLine($"Image Coverage: {analysis.ImageCoveragePercentage:F1}%");
}

// Extract text content
var textResult = await PdfPro.Read()
    .FromFile("document.pdf")
    .ExtractText()
    .ReadPdfAsync();

if (textResult.IsSuccess)
{
    var content = textResult.Data;
    Console.WriteLine($"Title: {content.DocumentInfo.Title}");
    Console.WriteLine($"Author: {content.DocumentInfo.Author}");
    Console.WriteLine($"Pages: {content.DocumentInfo.PageCount}");
    Console.WriteLine($"Text: {content.Text}");
}

// Extract images
var imageResult = await PdfPro.Read()
    .FromFile("document.pdf")
    .ExtractImages()
    .ReadPdfAsync();

if (imageResult.IsSuccess)
{
    foreach (var image in imageResult.Data.Images)
    {
        Console.WriteLine($"Image: {image.Name} ({image.Width}x{image.Height}) - {image.Format}");
        if (image.ImageData != null)
        {
            await File.WriteAllBytesAsync($"extracted_{image.Name}.jpg", image.ImageData);
        }
    }
}

Configuration and Options

using BizzelTech.PdfPro;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

// With dependency injection
services.AddLogging();
services.AddScoped<IPdfProBuilder, PdfProBuilder>();

// Custom configuration
var result = await PdfPro.Create()
    .FromHtml(htmlContent)
    .WithPageSize(PageSize.Custom, 800, 600) // Custom dimensions
    .WithOrientation(PageOrientation.Landscape)
    .WithMargins(top: 25, right: 25, bottom: 25, left: 25)
    .WithBaseUrl("https://mysite.com/") // For relative URLs in HTML
    .WithCss(customCss)
    .WithScss(customScss)
    .WithTemplateData(data)
    .WithMetadata(meta => meta
        .SetTitle("Custom Document")
        .SetAuthor("Your Name")
        .SetSubject("Important Document")
        .SetKeywords("pdf, generation, custom"))
    .GeneratePdfAsync();

Error Handling

All operations return PdfOperationResult<T> with comprehensive error information:

var result = await PdfPro.Create()
    .FromHtml(html)
    .GeneratePdfAsync();

if (result.IsSuccess)
{
    // Use result.Data
    Console.WriteLine($"Success: Generated {result.Data.Length} bytes");
}
else
{
    // Handle errors
    Console.WriteLine($"Error: {result.ErrorMessage}");
    if (result.Exception != null)
    {
        Console.WriteLine($"Exception: {result.Exception.Message}");
    }
}

API Reference

PdfPro Static Class

  • Create() - Start PDF generation pipeline
  • Read() - Start PDF reading pipeline

Generation Methods

  • FromHtml(string html) - Generate from HTML string
  • FromFile(string path) - Generate from HTML file
  • FromVueTemplate(string template) - Generate from Vue.js template

Configuration Methods

  • WithPageSize(PageSize size) - Set page size
  • WithOrientation(PageOrientation orientation) - Set page orientation
  • WithMargins(float top, right, bottom, left) - Set page margins
  • WithCss(string css) - Add CSS styles
  • WithScss(string scss) - Add SCSS styles (compiled automatically)
  • WithTemplateData(object data) - Set template variables
  • WithBaseUrl(string url) - Set base URL for relative links
  • WithMetadata(Action<MetadataBuilder> configure) - Set PDF metadata

Reading Methods

  • FromFile(string path) - Read from PDF file
  • FromBytes(byte[] data) - Read from byte array
  • ExtractText() - Include text extraction
  • ExtractImages() - Include image extraction
  • AnalyzeContent() - Include content analysis

Execution Methods

  • GeneratePdfAsync() - Execute PDF generation
  • ReadPdfAsync() - Execute PDF reading
  • AnalyzePdfAsync() - Execute PDF analysis

Requirements

  • .NET 8.0 or higher
  • Windows, macOS, or Linux

Dependencies

  • iText7 - PDF manipulation
  • iText7.pdfHtml - HTML to PDF conversion
  • LibSassHost - SCSS compilation
  • HtmlAgilityPack - HTML processing
  • Microsoft.Extensions.Logging - Logging support

License

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

Support

For issues, feature requests, or questions:

Contributing

Contributions are welcome! Please read our contributing guidelines and submit pull requests to our 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 is compatible.  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.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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.0.0 132 9/11/2025