Some test text!

Search
Hamburger Icon

Xamarin / Guides

Quick start - view a document in Xamarin

This tutorial only applies to Xamarin.iOS. See Xamarin.Android equivalent here .

This guide demonstrates how to display a PDF. To begin working with Apryse SDK, you must have first added it to your project .

  1. Add a PDF to your project:

    • Right click on Resources
    • Click on Add > Add Files
    • Choose a file (in this tutorial, let's say we added a sample.pdf) and confirm add
    • Make sure the Build Action of the file is set to BundleResource
  1. Apryse must be initialized before using any Apryse classes. This only needs to be done once. This is done as shown:

    Trial license key required.
    The trial of Apryse SDK requires a trial key. A commercial license key is required for use in a production environment. Please fill out our licensing form if you do not have a valid license key.
    Keep your license keys confidential.
    License keys are uniquely generated. Please make sure that it is not publicly available (e.g. in your public GitHub).
    PDFNet.Initialize("<key-goes-here>");
  2. At the top of your source file, import PDFNet and Tools.

    using pdftron;
    using pdftron.PDF.Controls;
  3. The following shows how to create a document viewer, set the document to display, and present it on screen.

    // Create a PTDocumentController
    var documentController = new PTDocumentController();
    
    // The PTDocumentController must be in a navigation controller before a document can be opened
    var navigationController = new UINavigationController(documentController);
    
    // Open an existing local file URL.
    var fileURL = NSBundle.MainBundle.GetUrlForResource("sample", "pdf");
    
    bool success = documentController.OpenDocumentWithURL(fileURL);
    
    // Show navigation (and document) controller.
    this.PresentViewController(navigationController, true, null);

Trial setup questions? Ask experts on Discord
Need other help? Contact Support
Pricing or product questions? Contact Sales