惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hacker News: Ask HN
Hacker News: Ask HN
IT之家
IT之家
S
SegmentFault 最新的问题
T
Tailwind CSS Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美
J
Java Code Geeks
博客园 - 聂微东
雷峰网
雷峰网
阮一峰的网络日志
阮一峰的网络日志
The Cloudflare Blog
博客园_首页
大猫的无限游戏
大猫的无限游戏
博客园 - 三生石上(FineUI控件)
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 【当耐特】
腾讯CDC
Apple Machine Learning Research
Apple Machine Learning Research
酷 壳 – CoolShell
酷 壳 – CoolShell
V
V2EX
宝玉的分享
宝玉的分享
小众软件
小众软件
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Hugging Face - Blog
Hugging Face - Blog
月光博客
月光博客
NISL@THU
NISL@THU
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
Blog — PlanetScale
Blog — PlanetScale
aimingoo的专栏
aimingoo的专栏
L
LINUX DO - 热门话题
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
F
Fortinet All Blogs
博客园 - Franky
L
Lohrmann on Cybersecurity
S
Secure Thoughts
量子位
V
Vulnerabilities – Threatpost
Last Week in AI
Last Week in AI
博客园 - 叶小钗
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
L
LINUX DO - 最新话题
I
InfoQ
C
CERT Recently Published Vulnerability Notes
Security Archives - TechRepublic
Security Archives - TechRepublic
P
Proofpoint News Feed
G
GRAHAM CLULEY
Cisco Talos Blog
Cisco Talos Blog

Inside Nutrient

A guide to the invisible work behind documents Introducing Nutrient Documents for Salesforce: Native document generation and signing Document AI vs. traditional OCR: Choosing between OCR, AI, and hybrid pipelines PDF SDK compliance and security evaluation checklist for enterprise teams (2026) Invariant Corp replaces paper processes with Nutrient Workflow and scales without limits What is process mapping? A complete guide Nutrient vs. Conga Composer for Salesforce document generation (2026) Document routing: How to automate document distribution The CTO’s AI playbook: Why accountability architecture beats orchestration Compliance workflow automation: Why built-in compliance is table stakes Workflow diagrams: Examples, symbols, and how to build one that actually runs Digital forms: Replace paper forms with automated workflows Approval workflow software: How to automate approvals Why document-centric automation is different The CEO’s AI playbook: Why decision architecture beats model selection Nutrient SDK product updates for Q1 2026 PDF redaction verification: How to prove sensitive data is permanently removed What is a VPAT? The complete guide to accessibility conformance reports What is PDF/UA? The accessible PDF standard explained Salesforce eSignatures: Generate, sign, and track documents in one flow Online document viewer: Options, tradeoffs, and how to embed one Document viewer for web apps: React, Vue, Angular (2026) Best document viewers in 2026: A buyer’s guide How to edit a PDF in Python: Add text, images, and annotations Nutrient advances Workflow platform with agentic AI for enterprise-grade speed and consistency in document-heavy operations How to create a Salesforce quote template from opportunity data The business case for accessibility: Five ways it drives enterprise value Python PDF library comparison (2026): 7 libraries for developers Why your AI agent hallucinates PDF table data PDF.js limitations: When to upgrade to a commercial PDF SDK How Subject scaled 5× with Nutrient’s PDF SDK without rebuilding its document layer I replaced our sales training with an AI coach that runs in Slack — here’s what broke Redirecting to: https://securitybuzz.com/cybersecurity-news/why-enterprise-permissions-are-ais-most-dangerous-inheritance/ Nutrient .NET SDK vs. iText Core: Complete comparison for .NET developers DocuVieware: Support’s most frequently asked setup questions Introducing Nutrient Workflow How to convert PDF to Word in C# (.NET) When email and spreadsheets stop working: Work order approval workflows for field teams on the move Compliance with confidence: Why document-centric automation is the foundation of your mission Nutrient expands AI Assistant, automating multistep document workflows inside any application What is document generation? A developer’s guide to PDF generation Document Converter data flow and how real-time watermarks skip the queue PDF/UA compliance guide: Requirements, standards, and best practices Computers still can’t understand you How Athena Intelligence built AI agents for regulated enterprises with Nutrient’s document infrastructure How to convert HTML to PDF (2026): 4 methods from browser print to SDK How to build a document extraction pipeline with Nutrient Vision API OCR vs. intelligent document processing: Choosing the right document extraction engine Beyond OCR: How document intelligence eliminates manual processing in regulated industries Nutrient vs. IronPDF: Complete comparison for .NET developers Nutrient vs. Aspose.PDF: Complete comparison for .NET developers Redirecting to: https://fortune.com/2026/02/19/openclaw-who-is-peter-steinberger-openai-sam-altman-anthropic-moltbook/ Lufthansa Systems uses Nutrient to deliver reliable, scalable PDF rendering for pilots worldwide Nutrient vs. Syncfusion: Complete comparison for .NET developers React’s useTransition: The hook you’re probably using wrong First City Monument Bank streamlines banking processes with Nutrient Workflow Redirecting to: https://www.sdcexec.com/warehousing/automation/article/22957364/nutrient-workflow-automation-the-missing-link-in-supply-chain-efficiency The complete guide to digital signatures: PAdES, CAdES, and XAdES explained Nutrient Python SDK: Production-grade document processing for Python Introducing agentic document editing for web applications with AI Assistant Nutrient vs. QuestPDF: Complete comparison for .NET developers How we fixed the GdPicture license expiration (and what to do if you’re affected) Red team security testing with agentic AI The future of healthcare document automation Best healthcare workflow software compared Nutrient SDK product updates for Q4 2025 How Harvey scaled legal document workflows 50 percent MoM without rebuilding infrastructure HIPAA-compliant document management in hospitals How we optimized rendering performance while handling thousands of annotations in React — Part 2 Automated PII removal with Nutrient API Redirecting to: https://www.devopsdigest.com/2026-low-code-no-code-predictions Redirecting to: https://www.kmworld.com/Articles/Editorial/ViewPoints/Leaders-predict-AI-to-continue-permeating-all-aspects-of-KM-in-2026-172594.aspx What are deep agents and how do they solve complex problems? Whipping up document magic: Your easy-bake recipe for Vue and Nutrient Web SDK 🧁 What I’ve learned about product iteration planning while building SDKs Passwordless document signing: Three-layer security guide New zip folder functionality streamlines file management in Document Automation Server The keyboard shortcuts playbook: Taking control of keyboard events in Nutrient Web SDK From experienced engineer to AI beginner: My unexpected journey AI-assisted manual testing: Handling Safari’s PDF rendering and UI quirks How to keep a 20-year-old SDK up to date How we optimized rendering performance while handling thousands of annotations in React — Part 1 Nutrient announces new executive hires to accelerate next phase of growth High performance UI using web workers Automate document conversion at scale with Python and Nutrient DCS From curiosity to PLG (and AI): My journey to understanding product-led growth Prost to progress: One year as Nutrient Pigeon usage at Nutrient: Bridging native SDKs to Flutter Modernizing CI build servers: How to migrate from Chef to Ansible Unix man pages: AI-friendly documentation since 1971 Consistent hashing for even load distribution Best AI redaction APIs: Complete comparison guide for 2025 Why AI document redaction matters for modern security From coding to coordinating: How AI transformed my workflow What is intelligent document processing (IDP)? A complete guide Enterprise PDF SDKs: Best PSPDFKit (now Nutrient) alternatives Nutrient SDK product updates for Q3 2025 GdPicture support best practices Redacting sensitive data with Nutrient AI redaction API How AI is transforming the customer experience at Nutrient: From instant answers to intelligent support
How to sign a PDF on iOS with Nutrient’s signature library
Stefan Kieleithner · 2024-07-04 · via Inside Nutrient

Table of contents

    How to sign a PDF on iOS with Nutrient’s signature library

    Summary

    This comprehensive tutorial demonstrates how to implement electronic and digital signatures in iOS applications using Nutrient’s iOS signature library. It covers both ink and image-based electronic signatures with step-by-step code examples. The guide includes instructions for generating certificates, creating ink annotations, adding image stamps, and programmatically marking annotations as signatures for secure PDF document signing workflows.

    In this post, you’ll learn how to programmatically add electronic and digital signatures to a PDF in your iOS application using Nutrient’s iOS signature library.

    This post will also cover how to generate a self-signed certificate authority (CA) certificate, a CA private key, a signer certificate, and a private key required for a digital signature.

    Requirements

    To get started, you’ll need:

    Getting started

    To follow along, create a fresh Xcode project and add Nutrient to your project. For step-by-step instructions, follow our getting started on iOS guide.

    Adding electronic signatures programmatically on iOS

    If you want users to provide their signature, you can also use Nutrient’s built-in signing user interface. See our adding electronic signatures guide to learn more.

    Electronic signatures in Nutrient are sometimes referred to as signature annotations because they’re modeled using annotations.

    Electronic signatures can either be an ink annotation or a stamp annotation. You can mark an annotation as a signature by setting the isSignature property to true.

    Signature annotations can be created, updated, and deleted if your license includes either the Annotations component or the Electronic Signatures component. If your license includes Electronic Signatures but not Annotations, then signatures are the only type of annotation that can be modified.

    1. Import PSPDFKit and PSPDFKitUI at the top of your UIViewController subclass implementation:

      import PSPDFKit

      import PSPDFKitUI

    2. Get the document you want to sign. You can use our sample PDF(opens in a new tab), which has a signature form element. After downloading the document, add it to your project:

      let fileURL = Bundle.main.url(forResource: "Form", withExtension: "pdf")!

      let document = Document(url: fileURL)

    3. Create an ink annotation:

      let annotation = InkAnnotation()

      annotation.color = UIColor(red: 0.7, green: 0.3, blue: 0.8, alpha: 1)

      annotation.lineWidth = 5

      // This example code is just hardcoding a stroke with three points.

      let lines = [[

      DrawingPoint(location: CGPoint(x: 450, y: 130), intensity: 0.5),

      DrawingPoint(location: CGPoint(x: 550, y: 30), intensity: 0.5),

      DrawingPoint(location: CGPoint(x: 650, y: 100), intensity: 0.5)

      ]]

      annotation.lines = lines

    4. Mark the annotation as a signature:

      annotation.isSignature = true

    5. Add the annotation to the document:

      document.add(annotations: [annotation])

    6. Present the PDF view controller:

      let pdfController = PDFViewController(document: document)

      // Present the PDF view controller within a `UINavigationController` to show built-in toolbar buttons.

      present(UINavigationController(rootViewController: pdfController), animated: true)

    7. You’ll now have the following in your ViewController.swift file:

      import UIKit

      import PSPDFKit

      import PSPDFKitUI

      class ViewController: UIViewController {

      override func viewDidAppear(_ animated: Bool) {

      super.viewDidAppear(animated)

      // Update to use your document name.

      let fileURL = Bundle.main.url(forResource: "Form", withExtension: "pdf")!

      let document = Document(url: fileURL)

      // Create the ink annotation.

      let annotation = InkAnnotation()

      annotation.color = UIColor(red: 0.7, green: 0.3, blue: 0.8, alpha: 1)

      annotation.lineWidth = 5

      // This example code is just hardcoding a stroke with three points.

      let lines = [[

      DrawingPoint(location: CGPoint(x: 450, y: 130), intensity: 0.5),

      DrawingPoint(location: CGPoint(x: 550, y: 30), intensity: 0.5),

      DrawingPoint(location: CGPoint(x: 650, y: 100), intensity: 0.5)

      ]]

      annotation.lines = lines

      // Mark this ink annotation as a signature.

      annotation.isSignature = true

      // Add the annotation.

      document.add(annotations: [annotation])

      let pdfController = PDFViewController(document: document)

      // Present the PDF view controller within a `UINavigationController` to show built-in toolbar buttons.

      present(UINavigationController(rootViewController: pdfController), animated: true)

      }

      }

      For a working example, replace the contents of your ViewController.swift with the code above.

    8. Run your application:

    Similarly, to add an image signature, you’ll have the following in your ViewController.swift file:

    import UIKit

    import PSPDFKit

    import PSPDFKitUI

    class ViewController: UIViewController {

    override func viewDidAppear(_ animated: Bool) {

    super.viewDidAppear(animated)

    // Update to use your document name.

    let fileURL = Bundle.main.url(forResource: "Form", withExtension: "pdf")!

    let document = Document(url: fileURL)

    let signatureImage = UIImage(named: "signatureImage.png")

    // Create the stamp annotation.

    let annotation = StampAnnotation(image: signatureImage)

    annotation.boundingBox = CGRect(x: 450, y: 50, width: 240, height: 100)

    // Mark this stamp annotation as a signature.

    annotation.isSignature = true

    // Add the annotation.

    document.add(annotations: [annotation])

    let pdfController = PDFViewController(document: document)

    // Present the PDF view controller within a `UINavigationController` to show built-in toolbar buttons.

    present(UINavigationController(rootViewController: pdfController), animated: true)

    }

    }

    For more information on electronic signatures, refer to our guide on how to add an electronic signature.

    Adding digital signatures programmatically on iOS

    Digital signatures are signed with a certificate. For demonstration purposes, this next section uses a self-signed certificate.

    Never use self-signed certificates in a production application. Always obtain them from a trust service provider (TSP) to ensure the verification of the signer’s identity.

    Generating a self-signed certificate

    To generate a self-signed certificate with OpenSSL(opens in a new tab), follow the steps outlined below.

    1. Generate a private key file named test-ca.key:

      openssl genrsa -out test-ca.key 2048

    2. Create and sign a certificate file named test-ca.cert for a CA with the common name (CN) My Test CA v1:

      openssl req \

      -x509 -new -nodes -key test-ca.key \

      -subj "/CN=My Test CA v1" \

      -days 3650 -reqexts v3_req -extensions v3_ca \

      -out test-ca.cert

    3. Create a signing certificate. Generate a private key file named test-signer.key and a certificate signing request file named test-signer.csr with the CN My Testing Document Signer:

      openssl req \

      -utf8 -nameopt oneline,utf8 -new -newkey rsa:2048 -nodes \

      -subj "/CN=My Testing Document Signer" \

      -keyout test-signer.key -out test-signer.csr

    4. Create a signing certificate file from the request and name it test-signer.cert:

      openssl x509 \

      -days 365 \

      -CA test-ca.cert -CAkey test-ca.key -CAcreateserial \

      -in test-signer.csr -req \

      -out test-signer.cert

    5. Generate a personal information exchange (.p12) file with:

      openssl pkcs12 -export -legacy -in test-signer.cert -inkey test-signer.key -out test-signer.p12 -password pass:test

    This will create a .p12 file with test as its password.

    Adding digital signatures to your document

    1. Add the test-signer.p12 and test-ca.cert files to your application by dragging them into your Xcode project.

    2. Get the document you want to sign:

      let fileURL = Bundle.main.url(forResource: "Form", withExtension: "pdf")!

      let document = Document(url: fileURL)

    3. Create a PKCS12 instance and get its certificates and private key. The signing process produces the signature by encrypting the message digest from the PDF file with a private key. The certificate, along with its public key, is added to the signature and saved in the PDF file:

      let p12URL = Bundle.main.url(forResource: "test-signer", withExtension: "p12")!

      guard let p12data = try? Data(contentsOf: p12URL) else {

      return print("Error reading p12 data from \(String(describing: p12URL))")

      }

      let p12 = PKCS12(data: p12data)

      let (certificates, privateKey) = try! p12.unlockCertificateChain(withPassword: "test")

      Replace test with your actual password.

    4. Add the CA certificate to the trust store for the signature validation process:

      let caCertificates = try! X509.certificates(fromPKCS7Data: Data(contentsOf: Bundle.main.url(forResource: "test-ca", withExtension: "cert")!))

      for certificate in caCertificates {

      SDK.shared.signatureManager.addTrustedCertificate(certificate)

      }

    5. Get the signature form element:

      let signatureFormElement = document.annotations(at: 0, type: SignatureFormElement.self).first!

    6. Now, sign the document:

      let fileName = "\(UUID().uuidString).pdf"

      let url = URL(fileURLWithPath: NSTemporaryDirectory().appending(fileName))

      Task {

      do {

      let configuration = SigningConfiguration(dataSigner: privateKey, certificates: certificates)

      try await document.sign(formElement: signatureFormElement, configuration: configuration, outputDataProvider: FileDataProvider(fileURL: url))

      let signedDocument = Document(url: url)

      } catch {

      print(error)

      }

      }

    7. Finally, present the PDF view controller showing the signed document:

      let pdfController = PDFViewController(document: signedDocument)

      // Present the PDF view controller within a `UINavigationController` to show built-in toolbar buttons.

      present(UINavigationController(rootViewController: pdfController), animated: true)

    8. Putting it all together will result in the following in your ViewController.swift file:

      import UIKit

      import PSPDFKit

      import PSPDFKitUI

      class ViewController: UIViewController {

      override func viewDidAppear(_ animated: Bool) {

      super.viewDidAppear(animated)

      // Update to use your document name.

      let fileURL = Bundle.main.url(forResource: "Form", withExtension: "pdf")!

      let document = Document(url: fileURL)

      let p12URL = Bundle.main.url(forResource: "test-signer", withExtension: "p12")!

      guard let p12data = try? Data(contentsOf: p12URL) else {

      return print("Error reading p12 data from \(String(describing: p12URL))")

      }

      let p12 = PKCS12(data: p12data)

      let (certificates, privateKey) = try! p12.unlockCertificateChain(withPassword: "test")

      // Add CA certificates to the trust store for the signature validation process.

      let caCertificates = try! X509.certificates(fromPKCS7Data: Data(contentsOf: Bundle.main.url(forResource: "test-ca", withExtension: "cert")!))

      for certificate in caCertificates {

      SDK.shared.signatureManager.addTrustedCertificate(certificate)

      }

      let signatureFormElement = document.annotations(at: 0, type: SignatureFormElement.self).first!

      let fileName = "\(UUID().uuidString).pdf"

      let url = URL(fileURLWithPath: NSTemporaryDirectory().appending(fileName))

      Task {

      do {

      let configuration = SigningConfiguration(dataSigner: privateKey, certificates: certificates)

      try await document.sign(formElement: signatureFormElement, configuration: configuration, outputDataProvider: FileDataProvider(fileURL: url))

      let signedDocument = Document(url: url)

      let pdfController = PDFViewController(document: signedDocument)

      // Present the PDF view controller within a `UINavigationController` to show built-in toolbar buttons.

      present(UINavigationController(rootViewController: pdfController), animated: true)

      } catch {

      print(error)

      }

      }

      }

      }

      For a working example, replace the contents of ViewController.swift with the code above.

    9. Run your application.

    For more information on digital signatures, refer to our digital signatures guide.

    Conclusion

    In this post, you learned how to add electronic and digital signatures to a document using the Nutrient library on iOS. If you hit any snags, don’t hesitate to reach out to our Support team for help.

    At Nutrient, we offer a commercial, feature-rich, and completely customizable iOS PDF library that’s easy to integrate and comes with well-documented APIs to handle advanced use cases. For more information, visit our overview page.

    FAQ

    Any PDF can be signed directly on your iPhone using electronic or digital signatures. This means you can open a PDF document and add your signature by drawing it on the screen or using a digital certificate, ensuring the document is authenticated and legally binding.

    Open the PDF in an app using Nutrient, apply a digital certificate or select the signature tool and draw or type your signature, and save the signed document.

    Explore related topics

    Try for free Ready to get started?

    Related SDK articles

    Explore more