I'm builting iOS app in Swift 4.2 that can make signature to PDF file. But in case Embeding the signature as PDFAnnotation, it can editable in apple's Preview app or other app which can edit pdf. How can I disable to edit PDFAnnoations ??
"Signature" is creates by UIImage which converted handwriting beizerpaths.
class SignatureAnnotation: PDFAnnotation {
var image: UIImage!
init(with image: UIImage!, forBounds bounds: CGRect, withProperties properties: [AnyHashable : Any]?) {
super.init(bounds: bounds,
forType: PDFAnnotationSubtype.freeText,
withProperties: properties)
self.image = image
}
required init?(coder aDecoder: NSCoder) {
fatalError()
}
override func draw(with box: PDFDisplayBox, in context: CGContext) {
guard let cgImage = self.image.cgImage else { return }
context.draw(cgImage, in: self.bounds)
}
}
func embedSignatureToPDF() {
let page = pdfView.currentPage
let signatureAnnotation = SignatureAnnotation(with: signature, forBounds: signatureRect, withProperties: nil)
page.addAnnotation(signatureAnnotation)
}