QPdfNet 1.5.1
dotnet add package QPdfNet --version 1.5.1
NuGet\Install-Package QPdfNet -Version 1.5.1
<PackageReference Include="QPdfNet" Version="1.5.1" />
paket add QPdfNet --version 1.5.1
#r "nuget: QPdfNet, 1.5.1"
// Install QPdfNet as a Cake Addin #addin nuget:?package=QPdfNet&version=1.5.1 // Install QPdfNet as a Cake Tool #tool nuget:?package=QPdfNet&version=1.5.1
What is QPdfNet
A C# wrapper for QPDF that exposes all the functionality that is available through the QPDF command-line tool
It supports linearization, encryption, and numerous other features. It can also be used for splitting and merging files, creating PDF files (but you have to supply all the content yourself), and inspecting files for study or analysis. QPDF does not render PDFs or perform text extraction, and it does not contain higher-level interfaces for working with page contents. It is a low-level tool for working with the structure of PDF files and can be a valuable tool for anyone who wants to do programmatic or command-line-based manipulation of PDF files.
The QPDF Manual is hosted online at https://qpdf.readthedocs.io. The project website is https://qpdf.sourceforge.io. The source code repository is hosted at GitHub: https://github.com/qpdf/qpdf.
License Information
QPdfNet is Copyright (C) 2021-2022 Magic-Sessions and is licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Microsoft Visual C++ runtimes
The DLL qpdf29.dll is compiled with Visual Studio 2022 you need these C++ runtimes for it on your computer
- X86: https://aka.ms/vs/17/release/vc_redist.x86.exe
- X64: https://aka.ms/vs/17/release/vc_redist.x64.exe
How to use
Getting the amount of pages
var job = new Job();
var result = job.InputFile(Path.Combine("TestFiles", "20_pages.pdf"))
.ShowNPages()
.Run(out var output);
Assert.AreEqual(ExitCode.Success, result);
Assert.AreEqual(output, "20");
Encrypting a PDF file
var outputFile = Path.Combine(_testFolder, "output_encryption_256_bit.pdf");
var job = new Job();
var result = job.InputFile(Path.Combine("TestFiles", "test.pdf"))
.OutputFile(outputFile)
.Encrypt("user", "owner", new Encryption256Bit(true, true, true, true, true, true, Modify.None, Print.None))
.Linearize()
.Run(out _);
Assert.AreEqual(ExitCode.Success, result);
Checking if a file is encrypted
var job = new Job();
var result = job.InputFile(Path.Combine("TestFiles", "encryption_256_bit.pdf"))
.IsEncrypted()
.RunIsEncrypted(out _);
Assert.AreEqual(ExitCodeIsEncrypted.Encrypted, result);
See the test project for more examples https://github.com/Sicos1977/QPdfNet/blob/main/QpdfNetTest/QpdfTests.cs
Logging
QPdfNet uses the Microsoft ILogger interface (https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.ilogger?view=dotnet-plat-ext-5.0). You can use any logging library that uses this interface.
The following 3 loglevels are used:
- LogInformatie: Logs information about the usage of QPdfNet
- LogError: Logs any errors that occurs
- LogDebug: Logs debug information
QPdfNet has some build in loggers that can be found in the QPdfNet.Logger
namespace.
For example
var logger = !string.IsNullOrWhiteSpace(<some logfile>)
? new QPdfNet.Loggers.Stream(File.OpenWrite(<some logfile>))
: new QPdfNet.Loggers.Console();
var job = new Job(logger);
Installing via NuGet
The easiest way to install MSGReader is via NuGet.
In Visual Studio's Package Manager Console, simply enter the following command:
Install-Package QPdfNet
Core Team
Sicos1977 (Kees van Spelde)
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
.NET Framework | net is compatible. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- Microsoft.Extensions.Logging (>= 9.0.0)
- Newtonsoft.Json (>= 13.0.3)
-
.NETStandard 2.1
- Microsoft.Extensions.Logging (>= 9.0.0)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on QPdfNet:
Package | Downloads |
---|---|
InfotechHelpers.AspNetFramework.PDFLibrary
INFO-TECH PDF Library using Puppeteersharp and QPDFNet |
|
InfotechHelpers.NetCore.PDFLibrary
INFO-TECH PDF Library using Puppeteersharp and QPDFNet |
GitHub repositories
This package is not used by any popular GitHub repositories.
- Updated to QPDF version 11.9.1