Skip to content

0.0.3

Choose a tag to compare

@gvreddy04 gvreddy04 released this 14 Nov 16:24
· 232 commits to main since this release
e382ac0

UnlimitedPDF — Release Notes

v0.0.3 — 2025-11-14

Compare: v0.0.2...v0.0.3

Summary

v0.0.3 introduces a full table API, improved document save APIs (including async overloads), many internal robustness and safety improvements, documentation/demo updates, and a package bump to 0.0.3. This release adds first-class support for building tabular content (rows, columns, cells, borders, colors) and a renderer to emit table content into PDF pages. It also makes several internal model classes safer and more immutable and modernizes the stream writing pipeline.

Highlights

  • New table features: PdfTable, PdfTableRow, PdfTableColumn, PdfTableCell, PdfBorder, PdfColor.
  • New alignment & style enums: PdfCellHorizontalAlignment, PdfCellVerticalAlignment, PdfBorderStyle.
  • PdfPageBuilder gains AddTable(x, y, width) — build tables directly on pages.
  • New save API: PdfDocument.Save(...) (sync and async) — stream-first writing and SaveAsync overloads.
  • Demo and README updated: sample invoice showing table usage; screenshots added.
  • Project and NuGet packaging bumped to v0.0.3; README and nuget/README.md updated.
  • CODE_OF_CONDUCT.md added.

What’s new (detailed)

Added

  • Table model classes and helpers:
    • UnlimitedPDF/Models/Table/PdfTable.cs
    • UnlimitedPDF/Models/Table/PdfTableRow.cs
    • UnlimitedPDF/Models/Table/PdfTableColumn.cs
    • UnlimitedPDF/Models/Table/PdfTableCell.cs
    • UnlimitedPDF/Models/Table/PdfBorder.cs
    • UnlimitedPDF/Models/Table/PdfColor.cs
  • Enums:
    • UnlimitedPDF/Enums/PdfCellHorizontalAlignment.cs
    • UnlimitedPDF/Enums/PdfCellVerticalAlignment.cs
    • UnlimitedPDF/Enums/PdfBorderStyle.cs
  • PdfPageBuilder.AddTable(x, y, width) — returns PdfTable to programmatically create tables.
  • New stream-oriented save methods:
    • PdfDocument.Save(string path)
    • PdfDocument.Save(Stream stream)
    • Task PdfDocument.SaveAsync(string path, CancellationToken)
    • Task PdfDocument.SaveAsync(Stream, CancellationToken)
  • Demo updates and example invoice using new table API:
    • UnlimitedPDF.Demo.ConsoleApp/Program.cs
  • Documentation:
    • README.md and nuget/README.md updated with samples and screenshots.
  • Governance:
    • CODE_OF_CONDUCT.md

Changed / Improved

  • Internal refactor for safety and clarity:
    • Several internal model classes made sealed / more immutable (PdfCatalog, PdfDictionary, PdfFont, PdfHeader, PdfIndirectReference, PdfObject, PdfPageContentStream, PdfStreamObject, PdfTrailer, etc.).
    • Constructors added to many internal types instead of property-only initialization.
    • Null-safety and whitespace checks added where appropriate.
  • PDF writing pipeline:
    • Reworked to use stream.Position for offsets and to support asynchronous streaming of stream objects.
    • PdfStreamObject and related stream writing handle null/empty stream data safely.
  • Project file (UnlimitedPDF.csproj):
    • PackageId/Version/PackageVersion updated to 0.0.3.
    • Target frameworks expanded to include net10.0 and conditional package reference for net10.0.
  • Example code: replaced old Write(...) usage with Save(...).

Potential breaking changes & migration notes

Most changes are internal, but please review these migration points:

  1. PdfDocument.Write(...) → PdfDocument.Save(...)

    • If your code invoked PdfDocument.Write(path), update to PdfDocument.Save(path).
    • Async usage: use PdfDocument.SaveAsync(path) or PdfDocument.SaveAsync(stream, cancellationToken).
    • Example:
      • Old:
        • pdfDocument.Write("out.pdf");
      • New:
        • pdfDocument.Save("out.pdf");
        • await pdfDocument.SaveAsync("out.pdf", cancellationToken);
  2. Internals made more immutable / constructors added

    • Many internal classes now require construction parameters or expose read-only properties. These changes are internal implementation details and should not affect public API consumers unless you relied on internal types via reflection or internal/exposed constructors.
    • If your code created internal objects (e.g., PdfPageContentStream, PdfObject with property setting) adjust to new constructors where necessary.
  3. Content stream & object-number handling

    • The library now manages object numbering and content stream association more strictly. If your code manipulated low-level Pdf* internals, update to new constructors and object management flows.
  4. Table rendering text metrics

    • The built-in table renderer uses a simple text width approximation. If precise typography/layout is required, extend font metrics or use custom rendering.

Upgrade instructions

  1. Update NuGet package:

    • dotnet add package UnlimitedPDF --version 0.0.3
    • Or update your PackageReference to Version="0.0.3"
  2. Replace Write calls:

    • Search & replace PdfDocument.Write(...) → PdfDocument.Save(...)
    • Introduce SaveAsync where non-blocking I/O is required.
  3. If you used any internal types, inspect compilation warnings/errors and follow new constructors / signatures.

Quick migration examples

  • Simple save change:
// Before
pdfDocument.Write("invoice.pdf");

// After
pdfDocument.Save("invoice.pdf");
// or async
await pdfDocument.SaveAsync("invoice.pdf", CancellationToken.None);
  • Building a simple table (copy-ready example)
using UnlimitedPDF;
using UnlimitedPDF.Enums;
using UnlimitedPDF.Models.Table;

var doc = new PdfDocument();
var page = doc.AddPage();

// create a table at x=50, y=650 with total width 512 points
var table = page.AddTable(50, 650, 512);

// define columns (absolute or auto)
table.SetColumnWidths(40, 210, 60, 100, 102);

// header row
var header = table.AddRow();
header.GetCell(0).Text = "S.No.";
header.GetCell(0).Background = PdfColor.LightGray;
header.GetCell(1).Text = "Item Description";
header.GetCell(1).Background = PdfColor.LightGray;
// ... fill other headers ...

// add a data row
var row1 = table.AddRow();
row1.GetCell(0).Text = "1";
row1.GetCell(1).Text = "Wireless Keyboard";
row1.GetCell(2).Text = "2";
row1.GetCell(2).HAlign = PdfCellHorizontalAlignment.Right;

doc.Save("invoice-with-table.pdf");

Notes & known considerations

  • The table renderer uses an approximate GetTextWidth() helper. For higher fidelity typography, extend with real font metrics (e.g., glyph widths) or allow consumers to pass metrics.
  • If you target .NET 10.0, the project includes conditional references for net10.0 and adds the TFM to the build.
  • Demo updated to demonstrate real-world invoice scenario — use it as a starting point.

Full Changelog: v0.0.2...v0.0.3