A simple, .NET library for PDF creation with text and bitmap rendering, plus optional OCR functionality for text extraction.
using CreatePdf.NET;
await Pdf.Create(Dye.Black)
.AddText("Hello World")
.SaveAsync("text.pdf");
await Pdf.Create()
.AddPixelText("Hello World")
.SaveAsync("pixel.pdf");
await Pdf.Create()
.AddText("Hello World!")
.SaveAndOcrAsync("text-ocr-demo");
await Pdf.Create()
.AddPixelText("Hello World!")
.SaveAndOcrAsync("pixel-ocr-demo");
await Pdf.Create()
.AddText("Hello World!", Dye.Blue, TextSize.Large)
.AddLine()
.SaveAndOpenAsync("opens-the-pdf.pdf");
await Pdf.Create(Dye.White)
.AddPixelText("Hello World!", Dye.Red, Dye.Brown, PixelTextSize.Medium)
.AddLines(5)
.SaveAndShowDirectoryAsync("opens-the-directory.pdf");
// Basic OCR with default settings
await Pdf.Load(pdfStream).OcrAsync();
// Custom OCR settings for individual needs
await Pdf.Load(pdfStream).OcrAsync(new OcrOptions
{
Dpi = 600,
PageSegmentationMode = 3
});
Platform | Installation |
---|---|
macOS | brew install tesseract |
Windows | Download Tesseract and Ghostscript |
Linux | sudo apt-get install ghostscript tesseract-ocr |
Note: Only needed for OCR.
PDF generation works without it.
dotnet add package CreatePdf.NET --prerelease
- .NET 8.0, 9.0, or 10.0 SDK
This project is licensed under the MIT License.