https://github.com/ancplua/createpdf.net
A simple .NET library for PDF creation with text and bitmap rendering, plus optional OCR functionality
https://github.com/ancplua/createpdf.net
bitmap csharp dotnet ghostscript linux macos pdf pdfgeneration tesseract windows
Last synced: 6 months ago
JSON representation
A simple .NET library for PDF creation with text and bitmap rendering, plus optional OCR functionality
- Host: GitHub
- URL: https://github.com/ancplua/createpdf.net
- Owner: ANcpLua
- License: mit
- Created: 2025-07-11T09:30:04.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-07-11T12:02:00.000Z (7 months ago)
- Last Synced: 2025-07-11T12:05:54.050Z (7 months ago)
- Topics: bitmap, csharp, dotnet, ghostscript, linux, macos, pdf, pdfgeneration, tesseract, windows
- Language: C#
- Homepage: https://www.nuget.org/packages/CreatePdf.NET
- Size: 59.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://codecov.io/gh/ANcpLua/CreatePdf.NET)
[](https://dotnet.microsoft.com/download/dotnet/8.0) [](https://dotnet.microsoft.com/download/dotnet/9.0) [](https://dotnet.microsoft.com/download/dotnet/10.0)
[](https://www.nuget.org/packages/CreatePdf.NET/)
[](https://github.com/ANcpLua/CreatePdf.NET/blob/main/LICENSE)
[](https://hub.docker.com/r/ancplua/createpdf.net)
# CreatePdf.NET
A simple, .NET library for PDF creation with text and bitmap rendering, plus [optional OCR functionality](#to-enable-ocr-functionality) for text extraction.
## Usage
```cs
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");
```
### Stream-based PDF Processing
```cs
// 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
});
```
### To enable OCR functionality
| Platform | Installation |
|----------|-------------|
| **macOS** |`brew install tesseract` |
| **Windows** |Download [Tesseract](https://github.com/UB-Mannheim/tesseract/wiki) and [Ghostscript](https://www.ghostscript.com/download/gsdnld.html) |
| **Linux** |`sudo apt-get install ghostscript tesseract-ocr` |
> **Note**: Only needed for OCR.
>
> PDF generation works without it.
## Installation
```bash
dotnet add package CreatePdf.NET --prerelease
```
### Requirements
- .NET 8.0, 9.0, or 10.0 SDK
## License
This project is licensed under the [MIT License](LICENSE).