PDF libraries to wrap PDFium, iTextSharp, and Ghostscript, and applications of CubePDF series.
Clone or download
Latest commit a730ffb Nov 19, 2018



NuGet NuGet NuGet NuGet
AppVeyor Codecov

Cube.Pdf libraries wrap PDFium, Ghostscript, iText, and other third-party PDF libraries. The repository also has some implemented PDF applications, such as CubePDF, CubePDF Utility, CubePDF Page, and more. We will move CubePdfViewer to the repository. Libraries and applications are available for .NET Framework 3.5, 4.5 or more. Note that some projects are licensed under the GNU AGPLv3. See the License section for details.


Cube.Pdf and related libraries

You can install Cube.Pdf libraries from the Install-Package command or NuGet packages UI on Visual Studio. The Libraries provide functionality to treat third-party libraries as the same interface (except for the Cube.Pdf.Ghostscript). Basic interfaces of the Cube.Pdf are as follows:

For example, the following sample accesses a PDF document by using the iTextSharp library. And when you want to use the PDFium library, you only modify the description of "using Cube.Pdf.Itext" to "using Cube.Pdf.Pdfium".

// using Cube.Pdf.Itext;

// Set password directly or using Query<string>
var password = new Cube.Query<string>(e =>
    e.Result = "password",
    e.Cancel = false,

using (var reader = new DocumentReader(@"path/to/sample.pdf", password))
    // Do something with Pages, Metadata, Encryption, and more properties.

When you merge, extract, or remove existing PDF pages, the simplest code is as follow. Note that if you specify an IDocumentReader object to the Add method of an IDocumentWriter implementation class, the IDocumentWriter object automatically disposes the specified object before saving.

// using Cube.Pdf.Itext;
using (var writer = new DocumentWriter())
    var src0 = new DocumentReader("first.pdf", "password");
    var src1 = new DocumentReader("second.pdf", "password");

    writer.Add(src0.Pages[0], src0);
    writer.Add(src1.Pages[0], src1);

    // Disposes src0 and src1 before saving.


When you convert from PostScript to any other formats, you can use the Cube.Pdf.Ghostscript library. The following code converts to the PDF file.

// using Cube.Pdf.Ghostscript;
var converter = new PdfConverter
    Paper        = Paper.Auto,
    Orientation  = Orientation.Auto,
    ColorMode    = ColorMode.Rgb,
    Resolution   = 600,
    Compression  = Encoding.Jpeg,
    Downsampling = Downsampling.None,
    Version      = new Version(1, 7),
converter.Invoke(@"path\to\src.ps", @"path\to\dest.pdf");

For details, see the Readme in the Ghostscript directory.



CubePDF is a PDF converter which allows you to convert files from any applications (for example, Google Chrome, Firefox, Microsoft Edge, Microsoft Word, Excel, PowerPoint, and more), whenever you need it. The converter allows you to convert the files as easy as you can print the files; as a matter of fact, you can do it in the same manner as you print files. The application uses Ghostscript and iTextSharp.

You can get the executable installer from the download page (Japanese), or directly download link. Note that the installer always shows menus and other messages only in Japanese. Source codes of the CubePDF are in the Applications/Converter (except for the virtual printer).

CubePDF Utility


CubePDF Utility is a PDF editor which can insert, remove, move, rotate pages, add or modify some metadata (PDF version, title, author, subject, keywords, creator, page layout), and encryption settings through the graphical user interface (GUI). The application uses PDFium and iTextSharp.

You can get the executable installer from the download page (Japanese), or directly download link. Source codes of the CubePDF Utility are in the Applications/Editor.


Dependencies of Libraries are as follows. Applications may use some other third-party libraries.


  1. Fork Cube.Pdf repository.
  2. Create a feature branch from the stable branch (git checkout -b my-new-feature origin/stable). The master branch may refer some pre-released NuGet packages. See AppVeyor.yml if you want to build and commit in the master branch.
  3. Commit your changes.
  4. Rebase your local changes against the stable (or master) branch.
  5. Run test suite with the NUnit console or the Visual Studio (NUnit 3 test adapter) and confirm that it passes.
  6. Create new Pull Request.


Copyright © 2010 CubeSoft, Inc. Projects are respectively licensed as follows:


Name License
Cube.Pdf Apache 2.0
Cube.Pdf.Pdfium Apache 2.0
Cube.Pdf.Ghostscript GNU AGPLv3
Cube.Pdf.Itext GNU AGPLv3


Name License
CubePDF Utility GNU AGPLv3
CubePDF ImagePicker GNU AGPLv3

Note that trade names, trademarks, service marks, or logo images distributed in CubeSoft applications are not allowed to reuse or modify all or parts of them.