NkkinPdf 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package NkkinPdf --version 1.0.0
                    
NuGet\Install-Package NkkinPdf -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="NkkinPdf" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NkkinPdf" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="NkkinPdf" />
                    
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 NkkinPdf --version 1.0.0
                    
#r "nuget: NkkinPdf, 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 NkkinPdf@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=NkkinPdf&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=NkkinPdf&version=1.0.0
                    
Install as a Cake Tool

NkkinPdf

Tiny, fast, dependency-free PDF writer for .NET 8+ and .NET MAUI (Android, iOS, Windows).

  • Unicode text with subset-embedded TrueType fonts: only the glyphs you use are embedded, and text stays copyable and searchable.
  • Arabic and RTL: letter joining, lam-alef ligatures, bidi ordering of mixed Arabic/Latin/number lines, mirrored brackets.
  • Two fonts in one line: PdfFontSet draws Arabic with your Arabic font and Latin with your Latin font.
  • Layout: alignment (Left/Center/Right/Start/End), word wrap, ellipsis, tables with automatic page breaks.
  • Graphics: lines, rectangles (filled, stroked, rounded), PNG (with transparency) and JPEG images, clickable links.
  • Safe for Android release builds: no reflection, trimming- and AOT-compatible, culture-safe number output.

Quick start

using NkkinPdf;

var latin  = TrueTypeFont.Load(await FileSystem.OpenAppPackageFileAsync("Fonts/OpenSans-Regular.ttf"));
var bold   = TrueTypeFont.Load(await FileSystem.OpenAppPackageFileAsync("Fonts/OpenSans-Semibold.ttf"));
var arabic = TrueTypeFont.Load(await FileSystem.OpenAppPackageFileAsync("Fonts/Cairo-Regular.ttf"));
var text   = new PdfFontSet(latin, rtl: arabic);
var title  = new PdfFontSet(bold, rtl: arabic);

var doc  = new PdfDocument { Title = "Earnings report", Author = "Nkkinsoft" };
var page = doc.AddPage(PdfPageSize.A4);                 // coordinates: points, origin top-left

page.DrawText("Earnings report — تقرير الأرباح", title, 18, 36, 36, PdfColor.FromHex("#2563EB"));
page.DrawParagraph("Long text wraps inside the width. النص العربي يلتف تلقائياً أيضاً.", text, 11, 36, 70, page.Width - 72);
page.DrawImage(logoPngBytes, page.Width - 100, 30, 64, 64);   // PNG or JPEG, aspect ratio kept
page.AddLink(36, 120, 120, 14, "https://example.com");

doc.Save(path);   // or doc.ToArray() / doc.SaveAsync(stream)

Load each font once and reuse it. A plain TrueTypeFont can be passed anywhere a PdfFontSet is expected.

Tables

var table = new PdfTable(text, 10) { HeaderFont = title };
table.AddColumn("Date", 80)
     .AddColumn("App")                                  // width 0 = share the remaining width
     .AddColumn("Earnings", 70, PdfTextAlign.End);
foreach (var r in rows) table.AddRow(r.Date, r.App, r.Earnings.ToString("F2"));

var y = table.Draw(doc, ref page, x: 36, y: 140, width: page.Width - 72);   // adds pages as needed

Cells wrap, the header repeats on each new page, rows are zebra-striped, and RightToLeft = true lays the columns out from the right for Arabic tables.

Fonts

  • TrueType (.ttf, glyf outlines) fonts are supported. CFF-based .otf fonts and .ttc collections are not.
  • PdfFontSet(latin, rtl, params fallbacks): Arabic/Hebrew letters use rtl, other letters use latin; digits, spaces and punctuation follow the surrounding text (set DigitsUseLatinFont = true to force 0-9 to the Latin font); characters neither font has go to the first fallback that has them.
  • The same font file loaded twice is embedded once per document.

Right-to-left text

Direction is detected from the first strong letter, or set it with PdfTextDirection.RightToLeft. PdfTextAlign.Start means right for RTL text and left for LTR text. Copy and search return the text in reading order (/ActualText). Joining forms come from the font's OpenType GSUB table, or from Unicode presentation forms when the font has them.

Performance

About 0.6 ms per page of text (500 pages, 22,500 lines in about 0.3 s, 562 KB), and a page of Arabic text is about 16 KB.

Limitations

  • Arabic diacritics (harakat) use the font's default positions (no GPOS mark positioning).
  • No kerning, no text justification yet.
  • Images: PNG and JPEG only.

License

MIT © Nkkinsoft

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.  net10.0 was computed.  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.
  • net8.0

    • No dependencies.

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
2.0.1 70 11/10/2026
2.0.0 91 11/3/2026
1.0.0 93 11/1/2026

First release: PdfDocument/PdfPage drawing API, subset TrueType embedding with ToUnicode, Arabic joining + lam-alef + bidi, PdfFontSet (Latin + RTL fonts), word wrap/ellipsis, PdfTable with page breaks and RTL layout, PNG/JPEG images, links.