Getting started on PSPDFKit.NET for iOS

Requirements

Creating a New dotnet Solution

  1. Open your terminal and change the current working directory to the ~/Downloads directory:

cd ~/Downloads
  1. Use the dotnet CLI to create a new iOS solution:

dotnet new ios -n PSPDFKit-Demo
Information

You can use dotnet new ios -h to learn more about the dotnet new ios command.

  1. Navigate to your newly created .NET iOS project directory, PSPDFKit-Demo:

cd ~/Downloads/PSPDFKit-Demo

Installing the PSPDFKit SDK via the dotnet CLI

  1. Use the dotnet CLI to add the PSPDFKit NuGet packages to your solution:

dotnet add package PSPDFKit.dotnet.iOS.Model
dotnet add package PSPDFKit.dotnet.iOS.UI
Information

You can use dotnet add package -h to learn more about the dotnet add package command.

  1. Open your solution in Visual Studio:

open PSPDFKit-Demo.csproj

Displaying a PDF

  1. Add the PDF document you want to display to your application by dragging it into your solution’s resources. On the dialog that’s displayed, select OK to accept the default integration options. You can use this Quickstart Guide PDF as an example.

drag-and-drop-document

  1. Import PSPDFKit and PSPDFKitUI at the top of your ViewController.cs file:

using PSPDFKit.Model;
using PSPDFKit.UI;
  1. Load your PDF document and display the view controller by implementing ViewDidAppear(Boolean) in the ViewController.cs file, like so:

public override void ViewDidAppear(bool animated)
{
	base.ViewDidAppear(animated);

	// Update to use your document name.
	var document = new PSPDFDocument(NSUrl.FromFilename("Document.pdf"));

	// The configuration object is optional and allows additional customization.
	var configuration = PSPDFConfiguration.FromConfigurationBuilder((builder) => {
		builder.PageMode = PSPDFPageMode.Single;
		builder.PageTransition = PSPDFPageTransition.ScrollContinuous;
		builder.ScrollDirection = PSPDFScrollDirection.Vertical;
	});
	var pdfViewController = new PSPDFViewController(document, configuration);

	// Present the PDF view controller within a `UINavigationController` to show built-in toolbar buttons.
	var navController = new UINavigationController(rootViewController: pdfViewController);
	_ = this.PresentViewControllerAsync(navController, animated: true);
}
  1. Build and run your application.

Next Steps

The PSPDFKit.NET (iOS) SDK exposes the APIs from PSPDFKit’s iOS SDK to .NET’s C# language. Refer to our guides, as they contain all the information you need to get started with PSPDFKit.

You can find more about the .NET integration in our GitHub project.

Requirements

Installing the PSPDFKit SDK via NuGet

  1. Open your solution in Visual Studio:

open path/to/YourSolution.sln
  1. Right-click your solution in Visual Studio and select the Manage NuGet Packages… menu:

manage-nuget-packages

  1. In the Browse section of nuget.org, search for PSPDFKIT.dotnet.

  2. Select the following two iOS packages: PSPDFKit.dotnet.iOS.Model and PSPDFKit.dotnet.iOS.UI:

add-pspdfkit-nuget-packages

  1. Tap the Add Packages button to add the NuGet packages to your solution.

Displaying a PDF

  1. Add the PDF document you want to display to your application by dragging it into your solution’s resources. On the dialog that’s displayed, select OK to accept the default integration options. You can use this Quickstart Guide PDF as an example.

drag-and-drop-document

  1. Import PSPDFKit and PSPDFKitUI at the top of your ViewController.cs file:

using PSPDFKit.Model;
using PSPDFKit.UI;
  1. Load your PDF document and display the view controller. This can be done just after the main activity is created in MainActivity::OnCreate, when a user clicks a button in a button action handler, or any time during your app’s lifecycle:

// Update to use your document name.
var document = new PSPDFDocument(NSUrl.FromFilename("Document.pdf"));

// The configuration object is optional and allows additional customization.
var configuration = PSPDFConfiguration.FromConfigurationBuilder((builder) => {
	builder.PageMode = PSPDFPageMode.Single;
	builder.PageTransition = PSPDFPageTransition.ScrollContinuous;
	builder.ScrollDirection = PSPDFScrollDirection.Vertical;
});
var pdfViewController = new PSPDFViewController(document, configuration);

// Present the PDF view controller within a `UINavigationController` to show built-in toolbar buttons.
var navController = new UINavigationController(rootViewController: pdfViewController);
_ = this.PresentViewControllerAsync(navController, animated: true);
  1. Build and run your application.

Next Steps

The PSPDFKit.NET (iOS) SDK exposes the APIs from PSPDFKit’s iOS SDK to .NET’s C# language. Refer to our guides, as they contain all the information you need to get started with PSPDFKit.

You can find more about the .NET integration in our GitHub project.

Requirements

Cloning the Sample Project

  1. Open your terminal and change the current working directory. In this case, use the ~/Downloads directory:

cd ~/Downloads
  1. Clone the PSPDFKit.NET (iOS) repository:

git clone https://github.com/PSPDFKit/dotnet-pdf-library-for-ios.git
  1. Change the current working directory to the root directory:

cd dotnet-pdf-library-for-ios
  1. Run the following command to build and download PSPDFKit and its dependencies:

./build.sh
  1. Open the samples solution (PSPDFKit.dotnet.Samples.sln) in Visual Studio:

open Samples/PSPDFKit.dotnet.Samples.sln
  1. Build and run the samples on Simulator, an iPhone, or your macOS computer.

catalog-simulator

Next Steps

The PSPDFKit.NET (iOS) SDK exposes the APIs from PSPDFKit’s iOS SDK to .NET’s C# language. Refer to our guides, as they contain all the information you need to get started with PSPDFKit.

You can find more about the .NET integration in our GitHub project.