Mavusi.PdfSharpCore
2.0.0
See the version list below for details.
dotnet add package Mavusi.PdfSharpCore --version 2.0.0
NuGet\Install-Package Mavusi.PdfSharpCore -Version 2.0.0
<PackageReference Include="Mavusi.PdfSharpCore" Version="2.0.0" />
<PackageVersion Include="Mavusi.PdfSharpCore" Version="2.0.0" />
<PackageReference Include="Mavusi.PdfSharpCore" />
paket add Mavusi.PdfSharpCore --version 2.0.0
#r "nuget: Mavusi.PdfSharpCore, 2.0.0"
#:package Mavusi.PdfSharpCore@2.0.0
#addin nuget:?package=Mavusi.PdfSharpCore&version=2.0.0
#tool nuget:?package=Mavusi.PdfSharpCore&version=2.0.0
PdfSharpCore (forked)
PdfSharpCore (forked by Mavusi) is a partial port of PdfSharp.Xamarin for .NET Standard. Additionally MigraDoc has been ported as well (from version 1.32). Native image support has been implemented for JPEG, PNG, and BMP formats without external dependencies. Font support provided by SixLabors.Fonts.
Original project by ststeiger → https://github.com/ststeiger/PdfSharpCore.
This fork added:
- Native image processing (JPEG, PNG, BMP) - no ImageSharp dependency required
- Lesser "accuracy level" (Pdf.IO.enums.PdfReadAccuracy.Lazy) for opening some broken PDFs
- Preliminary support for PDF Signatures validation (PdfDocument.IsSigned, PdfDocument.Signatures)
Table of Contents
Example
The following code snippet creates a simple PDF-file with the text 'Hello World!'. The code is written for a .NET 6 console app with top level statements.
using PdfSharpCore.Drawing;
using PdfSharpCore.Fonts;
using PdfSharpCore.Pdf;
using PdfSharpCore.Utils;
GlobalFontSettings.FontResolver = new FontResolver();
var document = new PdfDocument();
var page = document.AddPage();
var gfx = XGraphics.FromPdfPage(page);
var font = new XFont("Arial", 20, XFontStyle.Bold);
var textColor = XBrushes.Black;
var layout = new XRect(20, 20, page.Width, page.Height);
var format = XStringFormats.Center;
gfx.DrawString("Hello World!", font, textColor, layout, format);
document.Save("helloworld.pdf");
Publishing to NuGet
This package supports .NET 8, .NET 9, and .NET 10 through multi-targeting.
Before Publishing
Update Version Numbers
Before publishing a new version, update the version in all project files:
PdfSharpCore/Moondigo.PdfSharpCore.csprojPdfSharpCore.Charting/PdfSharpCore.Charting.csprojMigraDocCore.DocumentObjectModel/MigraDocCore.DocumentObjectModel.csprojMigraDocCore.Rendering/MigraDocCore.Rendering.csproj
Update the following properties:
<Version>1.0.1</Version> <AssemblyVersion>1.0.1.0</AssemblyVersion> <FileVersion>1.0.1.0</FileVersion>Note: Follow Semantic Versioning:
- MAJOR version for incompatible API changes
- MINOR version for new functionality in a backward compatible manner
- PATCH version for backward compatible bug fixes
Update Release Notes (optional but recommended)
Update the
<PackageReleaseNotes>property in each project file to describe what's new in this version.
Publishing Steps
Clean and Build in Release Mode
dotnet clean dotnet build -c ReleaseCreate NuGet Packages
Packages are automatically created during build (when
GeneratePackageOnBuildisTrue). Find them in:PdfSharpCore/bin/Release/PdfSharpCore.Charting/bin/Release/MigraDocCore.DocumentObjectModel/bin/Release/MigraDocCore.Rendering/bin/Release/
Alternatively, manually pack:
dotnet pack -c ReleasePublish to NuGet
Quick Publish (One Command)
Copy and paste this command to build and publish all packages at once:
$apiKey = "YOUR_API_KEY_HERE"; dotnet clean; dotnet build -c Release; Get-ChildItem -Path . -Recurse -Filter "*.nupkg" | Where-Object { $_.FullName -like "*\bin\Release\*" } | ForEach-Object { dotnet nuget push $_.FullName --source https://api.nuget.org/v3/index.json --api-key $apiKey --skip-duplicate }Or publish using wildcards:
# Navigate to each project's Release folder or use wildcards dotnet nuget push "**/*.nupkg" --source https://api.nuget.org/v3/index.json --api-key YOUR_API_KEY_HERE --skip-duplicateOr publish each package individually:
dotnet nuget push PdfSharpCore/bin/Release/Mavusi.PdfSharpCore.1.0.1.nupkg -s https://api.nuget.org/v3/index.json -k YOUR_API_KEY_HERENote: Get your NuGet API key from https://www.nuget.org/account/apikeys
Verify Publication
After publishing, verify your package appears at:
Multi-Targeting Support
The NuGet package includes binaries for:
net8.0net9.0net10.0
NuGet will automatically select the appropriate target framework based on the consuming project's target framework.
Contributing
We appreciate feedback and contribution to this repo!
License
This software is released under the MIT License. See the LICENSE file for more info.
PdfSharpCore relies on the following projects:
- SixLabors.Fonts (Apache 2.0 license when distributed as part of PdfSharpCore)
- See https://github.com/SixLabors/Fonts/blob/master/LICENSE for details
| 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 is compatible. 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 is compatible. 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. |
-
net10.0
- System.Security.Cryptography.Pkcs (>= 10.0.6)
-
net8.0
- System.Security.Cryptography.Pkcs (>= 10.0.6)
-
net9.0
- System.Security.Cryptography.Pkcs (>= 10.0.6)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Mavusi.PdfSharpCore:
| Package | Downloads |
|---|---|
|
Mavusi.HtmlRendererCore.PdfSharp
HtmlRendererCore is a partial port of HtmlRenderer for .NET Core. Supports rendering HTML to PDF using PdfSharp on .NET 8, 9, and 10. Includes bundled Liberation Fonts for Docker and cloud environments - no system fonts required! Lightweight with minimal dependencies - no ImageSharp required. |
GitHub repositories
This package is not used by any popular GitHub repositories.
PdfSharpCore (forked by Mavusi) is a partial port of PdfSharp.Xamarin for .NET Core. Removed ImageSharp and SharpZipLib dependencies