NkkinPdf 1.0.0
See the version list below for details.
dotnet add package NkkinPdf --version 1.0.0
NuGet\Install-Package NkkinPdf -Version 1.0.0
<PackageReference Include="NkkinPdf" Version="1.0.0" />
<PackageVersion Include="NkkinPdf" Version="1.0.0" />
<PackageReference Include="NkkinPdf" />
paket add NkkinPdf --version 1.0.0
#r "nuget: NkkinPdf, 1.0.0"
#:package NkkinPdf@1.0.0
#addin nuget:?package=NkkinPdf&version=1.0.0
#tool nuget:?package=NkkinPdf&version=1.0.0
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:
PdfFontSetdraws 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,glyfoutlines) fonts are supported. CFF-based.otffonts and.ttccollections are not. PdfFontSet(latin, rtl, params fallbacks): Arabic/Hebrew letters usertl, other letters uselatin; digits, spaces and punctuation follow the surrounding text (setDigitsUseLatinFont = trueto 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 | Versions 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. |
-
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.
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.