【问题标题】:Create PDF Annotations Using PDFKIt iOS 11使用 PDFKIt iOS 11 创建 PDF 注释
【发布时间】:2017-09-26 06:02:15
【问题描述】:

我实际上是在尝试使用 PDFKit 注释在 pdf 上绘制墨迹/freedraw 注释,但无法绘制注释。

在苹果提供的ink注解中,有一种方法可以在注解中添加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 上绘制注释。 预先感谢您提供所有宝贵的答案。

【问题讨论】:

  • 可以帮到我吗?我正在研究 pdf 工具包,我需要运行编辑器来创建 pdf。如果您有任何信息,如果可能的话,请更新您的代码或帮助我解决这个问题stackoverflow.com/questions/48609287/…
  • 你好@nedaDerakhshesh 实际上我们在 PDFKit 上做 POC,由于没有适当的文档,我们停止了工作。

标签: swift annotations ios11 pdfkit


【解决方案1】:

我不确定您是否对UIBezierPathPDFAnnotation 有疑问,但这里有一个工作示例。

@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)
}

【讨论】:

  • Rebacz 我试图执行这个,但没有工作,你能详细说明一下
  • override func viewDidLoad() { super.viewDidLoad(); pdfView.document = pdfFile; addInkAnnotation() } 就是这样。
  • 抱歉我的无知,但是您如何使用 PDFView 属性创建 pdfView 的出口,因为使用我的方法我将 pdfView 分配为运行文档上的子视图没有注释/没有感应笔的触摸
  • 创建出口: 1. 在界面生成器中添加一个子视图。 2. 将其类(自定义类)更改为 PDFView,如:ibb.co/bCOGV6 3. 在视图控制器中创建 outlet。就是这样;)
  • @RafałRębacz 如果您有任何关于如何使用 ios pdfkit 运行和保存编辑器的信息,请告诉我。非常感谢你。 stackoverflow.com/questions/48609287/…
猜你喜欢
  • 2018-03-25
  • 2011-07-10
  • 1970-01-01
  • 2018-04-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-06-08
  • 2018-04-18
相关资源
最近更新 更多