【发布时间】:2019-06-14 10:02:56
【问题描述】:
我正在使用 Swift 4.2 构建 iOS 应用程序,可以对 PDF 文件进行签名。 但是如果将签名嵌入为 PDFAnnotation,它可以在苹果的 Preview 应用程序或其他可以编辑 pdf 的应用程序中进行编辑。 如何禁用编辑 PDFAnnoations ??
“签名”是由 UIImage 创建的,它转换了手写 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)
}
【问题讨论】:
-
你找到答案了吗? ,我在我的应用中注意到了这种行为,但我没有找到任何解决方案来解决它
-
@Basil 你好,Basil。不,还没有解决...
标签: swift pdf pdf-annotations ios-pdfkit