QPdfNet 1.4.3

dotnet add package QPdfNet --version 1.4.3
NuGet\Install-Package QPdfNet -Version 1.4.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="QPdfNet" Version="1.4.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add QPdfNet --version 1.4.3
#r "nuget: QPdfNet, 1.4.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install QPdfNet as a Cake Addin
#addin nuget:?package=QPdfNet&version=1.4.3

// Install QPdfNet as a Cake Tool
#tool nuget:?package=QPdfNet&version=1.4.3

qpdf_c#

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

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.4.3 744 2/25/2024
1.4.2 111 2/17/2024
1.4.1 114 2/14/2024
1.4.0 125 2/11/2024
1.3.0 110 2/10/2024
1.2.1 664 7/31/2023

- Updated to QPDF version 11.9.0