使用PDFKIt创建PDF注释iOS 11
问题描述:
我实际上试图在PDF上使用PDFKit注释来绘制ink/freedraw注释,但无法绘制注释。使用PDFKIt创建PDF注释iOS 11
在由apple提供的墨迹注释中,有一种方法为注释添加Bezier路径。
// Add or remove paths from the annotation.
// Path points are specified in annotation space.
// Used by annotations type(s): /Ink.
open func add(_ path: UIBezierPath)
即使添加了路径,也不会在PDF上绘制注释。 非常感谢您提供所有宝贵的答案。
答
我不确定您是否有UIBezierPath
或PDFAnnotation
的问题,但这里是一个工作示例。
@IBOutlet weak var pdfView: PDFView!
func addInkAnnotation() {
let rect = CGRect(x: 100.0, y: 100.0, width: 100.0, height: 20.0)
let annotation = PDFAnnotation(bounds: rect, forType: .ink, withProperties: nil)
annotation.backgroundColor = .blue
let pathRect = CGRect(x: 0.0, y: 0.0, width: 10.0, height: 10.0)
let path = UIBezierPath(rect: pathRect)
annotation.add(path)
// Add annotation to the first page
pdfView.document?.page(at: 0)?.addAnnotation(annotation)
}
是否可以帮到我?我正在使用pdf套件,我需要运行编辑器来创建pdf。如果您有任何信息,如果可能的话,请通过您的代码或帮助我在这个问题https://stackoverflow.com/questions/48609287/how-to-create-a-pdf-from-image-which-taken-by- camera-with-pdfkit –
你好@nedaDerakhshesh其实我们是在PDFKit上做POC,由于缺乏适当的文档,我们停止了这个工作。 –