Zum Inhalt springen
NexPDF

Installation

Das NexPDF-NuGet-Paket zu einem .NET-Projekt hinzufügen und die native Engine-Bibliothek bereitstellen.

Deutsch

Paket hinzufügen

dotnet add package Nexdevit.NexPdf --version 1.1.0

Der Namespace ist Nexdevit.NexPdf.

Native Bibliothek beschaffen

Laden Sie das Archiv für Ihre Plattform aus dem Release v1.1.0 herunter:

PlattformArchivBibliothek
Linux x64nexpdf-ffi-1.1.0-linux-x64.tar.gzlib/libnexpdf_ffi.so
Linux arm64nexpdf-ffi-1.1.0-linux-arm64.tar.gzlib/libnexpdf_ffi.so
macOSnexpdf-ffi-1.1.0-macos-universal.tar.gzlib/libnexpdf_ffi.dylib
Windows x64nexpdf-ffi-1.1.0-windows-x64.ziplib/nexpdf_ffi.dll

Bibliothek dort ablegen, wo .NET sie findet

Zur Laufzeit lädt .NET nexpdf_ffi aus dem Anwendungsordner oder dem Systembibliothekspfad (LD_LIBRARY_PATH, DYLD_LIBRARY_PATH, PATH). Am einfachsten kopieren Sie sie in den Ausgabeordner:

MyApp.csproj
<ItemGroup>
  <None Include="native/libnexpdf_ffi.so" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

Installation prüfen

Console.WriteLine(Nexdevit.NexPdf.NexPdfSdk.Version);

Ein Paket, das die Engine enthält

NuGet kopiert die passende native Bibliothek neben die Anwendung, wenn das Paket pro Runtime Identifier eine unter runtimes/<rid>/native/ enthält. Um ein solches Paket aus dem SDK-Quellcode zu bauen, legen Sie die Bibliotheken dort ab und packen:

NexPdf.csproj
dotnet pack nexpdf-dotnet/NexPdf.csproj -c Release

Die macOS-Release-Bibliothek ist universal, daher kommt dieselbe Datei in beide osx--Ordner.

Docker

Dockerfile
FROM mcr.microsoft.com/dotnet/aspnet:8.0
ADD https://github.com/nexdevit/nexpdf-dotnet/releases/download/v1.1.0/nexpdf-ffi-1.1.0-linux-x64.tar.gz /tmp/
RUN tar -xzf /tmp/nexpdf-ffi-1.1.0-linux-x64.tar.gz -C /opt
ENV LD_LIBRARY_PATH=/opt/nexpdf-ffi-1.1.0-linux-x64/lib
COPY publish/ /app/
WORKDIR /app
ENTRYPOINT ["dotnet", "MyApp.dll"]

Auf dieser Seite