Skip to content

ComPDFKit/compdfkit-pdf-sdk-windows

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ComPDF SDK for Windows (.NET PDF Library)

As part of the KDAN ecosystem, ComPDF SDK for Windows is developed and maintained by ComPDF, enabling developers to quickly and seamlessly integrate advanced PDF functionalities—such as viewing, editing, annotating, filling forms, and signing—into Windows applications.

The ComPDF Windows PDF Library provides an easy-to-use .NET API that helps teams ship PDF features faster without complex integrations. You can start with a 30-day free trial license and evaluate the SDK in your own Windows project.

ComPDF SDK seamlessly operates on WebWindowsAndroidiOSMac, and Server, with support for cross-platform frameworks such as React NativeFlutter, etc.

If you find ComPDF SDK useful, please consider giving us a ⭐ Star on GitHub — it helps us grow and improve. Got questions or ideas? Join the conversation in our Discussions.

Windows demo GIF

Why ComPDF SDK for Windows?

  • Easy to Integrate: Integrate PDF functionalities easily with our powerful SDK and clear documentation and guides with few lines of code.

  • Fully Customizable UI: Design a unique interface for your products with fully customizable UI source code by a high-performing SDK.

  • Comprehensive PDF Features: Supports generation, viewing, annotation, page editing, content editing, conversion, OCR, redaction, signing, forms, parsing, measurement, compression, comparison, color separation, batch processing, and more.

  • Faster Time-to-Market: Comprehensive SDK libraries save your time and expenses and roll out your applications and projects.

  • High-quality Service: We provide 24/7 professional one-to-one technical support, including onsite service and remote assistance via phone and email.


Table of Contents

Related

Preview

ComPDF SDK for Windows delivers a smooth, feature-rich PDF experience for desktop applications.

ComPDF SDK for Windows

Requirements

Before starting, please make sure that you have already met the following prerequisites.

Get a ComPDF License Key

ComPDF provides two types of license key: a 30-day free trial license and a formal license.

How to Get a Free Trial License

Method 1: Apply Online

If you want to get PDF SDK trials for Web, Windows, Android, iOS, Flutter, and React Native, simply apply for a 30-day free trial license online.

You can check features supported by the free trial license on our Pricing page.

Method 2: Contact Sales

For other platforms or features outside of the trial license, feel free to contact our sales team.

How to Get a Formal License

ComPDF SDK is a commercial SDK that requires a license for application release. Any documents, sample code, or source code distribution from the released package of ComPDF to any third party is prohibited.

To get formal licenses for Windows platforms, advanced features, custom requirements, or quote inquiries, feel free to contact our sales team.

For the Windows PDF SDK, the formal license must be bound to your developer device ID (How to find the developer device ID), and each license is only valid for one device ID in development mode.

Download the PDF SDK

Download the ComPDF SDK for Windows on GitHub or NuGet.

System Requirements

Item Requirement
Operating System Windows 7, 8, 10, and 11 (32-bit and 64-bit)
IDE Visual Studio 2017 or higher (make sure .NET Desktop Development is installed)
Framework .NET Framework 4.5 or higher

How to Make a Windows Program in C#

This section will help you quickly get started with ComPDF SDK to build a Windows app in C# with step-by-step instructions. Through the following steps, you will get a simple application that can display the contents of a specified PDF file.

Video Guide: Create a C# PDF Viewer for Windows

image-youtube

Create a New Project

  1. Open Visual Studio 2022, and click Create a new project. vs2022_1

  2. Choose WPF App (.NET Framework) and click Next. vs2022_2

  3. Configure your project: Set your project name and choose the location to store your program. The project name is called "ComPDF Demo" in this example. This sample project uses .NET Framework 4.6.1 as the programming framework.

vs2022_3

  1. Click the Create button. Then, the new project will be created.

Install

There are two ways to add ComPDF to your Project: Nuget Repository and Local Package, you can choose one or the other according to your needs.

Nuget Repository

  1. Open your project's solution, and in the Solution Explorer, right-click on References and click on the menu item Manage NuGet Packages. This will open the NuGet Package Manager for your solution.

9

  1. Go to ComPDF.NetFramework in Nuget, and click on the Install button to install the package.

3

  1. Once that is complete, you'll see a reference to the package in the Solution Explorer under References. 4

Local Package

Rather than targeting a package held at Nuget, you may set up a configuration to point to a local package. This can be useful for some situations, for example, your build machines don't have access to the internet.

  1. You can find "ComPDF.NetFramework....nupkg" file in the SDK Package

  2. Create or edit a "nuget.config" file in the same directory as your solution file (e.g. "ComPDF Demo.sln").

5

  • The contents of the file should contain an XML element, packageSources - which describes where to find NuGet packages - as a child of a root node named configuration. If the file already exists, add the extra packageSources entry shown below. If the file is blank, copy and paste the entirety of the following contents:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <packageSources>
        <add key="ComPDFKitSource" value="path\to\directoryContainingNupkg" />
    </packageSources>
</configuration>
  • Edit the value of the contents to correctly refer to the location of the directory containing the "ComPDF.NetFramework....nupkg" package - for example, C:\Users\me\nugetPackages. Now save the file, and close and reopen your solution for Visual Studio to force a read of the NuGet configuration.
  1. Open your project's solution, and in the Solution Explorer, right-click on References and click on the menu item Manage NuGet Packages…. This will open the NuGet Package Manager for your solution. 6

  2. On the right-hand side of the manager in the Package source dropdown window, choose the entry ComPDFKitSource (or whatever you decided to name it). You should then see the entry for "ComPDF.NetFramework". 7

  3. On the right side, in the panel describing the package, click on the Install button to install the package. 8

  4. Once that's complete, you'll see a reference to the package in the Solution Explorer under References. 9

Apply the License Key

If you haven't get a license key, please check out [how to obtain a license key](###Get ComPDFKit License Key).

ComPDFKit PDF SDK currently supports two authentication methods to verify license keys: online authentication and offline authentication.

Learn about:

Copy the License Key

After getting the license key, follow the steps below to apply it to your project.

  1. In the email you received, locate the XML file containing the license key.

  2. Copy the license key XML file to your own project.

Apply the License Key

You can perform authentication using the following method:

public static bool LicenseVerify()
{
    if (!CPDFSDKVerifier.LoadNativeLibrary())
    { 
        return false;
    }
    string xmlPath = "The path to your license key XML file";
    LicenseErrorCode status = CPDFSDKVerifier.LicenseVerify(xmlPath);
    return status == LicenseErrorCode.E_LICENSE_SUCCESS;
}

Display a PDF Document

We have finished all prepare steps. Let's display a PDF file.

  1. Add the following code to "MainWindow.xaml" and "MainWindow.xaml.cs" to display a PDF document. Please make sure to replace "ComPDFKit_Demo" with the name of your project. Now, all you need to do is to create a CPDFViewer object, and then display the CPDFViewer object in the Grid (component) named "PDFGrid" using the OpenPDF_Click method.

  2. Now your "MainWindow.xaml" should look like the following code.

<Window x:Class="ComPDFKit_Demo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:ComPDFKit_Demo"
        xmlns:compdfkitviewer="clr-namespace:ComPDFKitViewer;assembly=ComPDFKit.Viewer"
        mc:Ignorable="d"
        Focusable="True"
        Title="MainWindow" Height="600" Width="800" UseLayoutRounding="True">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="52"/>
        </Grid.RowDefinitions>
        <Grid Name="PDFGrid" Grid.Row="0">
            <ScrollViewer Focusable="False" CanContentScroll="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                <compdfkitviewer:CPDFViewer x:Name="PDFViewer"/>
            </ScrollViewer>
        </Grid>
        <Button Content="Open PDF" Grid.Row="1" HorizontalAlignment="Left" Margin="10" Click="OpenPDF_Click"/>
    </Grid>
</Window>
  1. Now your “MainWindow.xaml.cs” should look like the following code. Please note: You need to enter your license key. All the places that need to be modified in the code have been marked with comments in the code below. You just need to replace the string content below the comments by yourself.
using ComPDFKit.NativeMethod;
using ComPDFKit.PDFDocument;
using Microsoft.Win32;
using System.Windows;

namespace ComPDFKit_Demo
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            LicenseVerify();
        }

        bool LicenseVerify()
        {
            if (!CPDFSDKVerifier.LoadNativeLibrary())
                return false;

            // Input your license.
            LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify("Input your license here.");
            return (verifyResult == LicenseErrorCode.E_LICENSE_SUCCESS);
        }

        private void OpenPDF_Click(object sender, RoutedEventArgs e)
        {
            // Get the path of a PDF file.
            var dlg = new OpenFileDialog();
            dlg.Filter = "PDF Files (*.pdf)|*.pdf";
            if (dlg.ShowDialog() == true)
            {
                // Use the PDF file path to open the document in CPDFViewer.
                CPDFDocument doc = CPDFDocument.InitWithFilePath(dlg.FileName);
                if (doc != null && doc.ErrorType == CPDFDocumentError.CPDFDocumentErrorSuccess)
                    PDFViewer.InitDoc(doc);
            }
        }
    }
}
  1. Now run the project and you will see the PDF file that you want to display. The PDF Viewer has been created successfully.

4

Troubleshooting

  1. License Verification Failed
  • If "System.IO.FileNotFoundException" occurred in the LicenseVerify() function like this:

vs2022_4

  • Check your WPF project and ensure that you chose WPF App(.NET Framework) instead of WPF Application when creating the project.

vs2022_5

  1. Other Problems If you encounter other integration issues while using ComPDF SDK for Windows, feel free to contact our support team.

Changelog

Keep up with the latest updates, improvements, and bug fixes for ComPDF SDK for Windows: View Windows Changelog

Free Trial & License

ComPDF SDK for Windows offers a 30-day free trial license so you can evaluate all core PDF capabilities in your own application.

To get started:

  1. Apply for a 30-day free trial license
  2. Review supported trial features on the Pricing page
  3. Follow the Apply the License Key steps above to activate the SDK in your project

For custom deployments, advanced features, or volume licensing, please contact our sales team

Support

ComPDF offers professional technical support and 5×24 responsive service.

About

Integration process and best practices for using a PDF library in Windows apps. Build powerful, accessible, and responsive user experiences with ease.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors