2017-09-26 5 views
1

저는 PDF에서 PDFKit 주석을 사용하여 잉크/자유형 주석을 그렸지만 주석을 그릴 수 없습니다.PDFKit을 사용하여 PDF 주석 만들기 iOS 11

사과가 제공하는 잉크 주석에는 주석에 베 지어 경로를 추가하는 방법이 있습니다.

// 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에 주석이 그려지지 않습니다. 모든 귀중한 답변을 미리 보내 주셔서 감사합니다.

+0

나를 도울 수 있습니까? 나는 pdf 킷에서 일하고 있는데 나는 pdf를 만들기 위해 편집자를 돌릴 필요가있다. 정보가 있으면 가능한 경우 코드를 작성하거나이 질문에 도움을주십시오. https://stackoverflow.com/questions/48609287/how-to-create-a-pdf-from-image-which-taken-by- camera-with-pdfkit –

+0

안녕하세요 @nedaDerakhshesh 실제로 우리는 PDFKit에서 POC를하고 있었고 적절한 문서를 사용할 수 없기 때문에 작업을 중단했습니다. –

답변

2

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) 
} 
+0

Rebacz이 작업을 실행하려했지만 아무 작업도하지 못했습니다. – Codicil

+0

'override func viewDidLoad() {super.viewDidLoad(); pdfView.document = pdfFile; addInkAnnotation()} ' 그리고 이것이 그 것이다. –

+0

내 방법에 대해 미안하지만 PDF 파일 속성이있는 pdfView의 콘센트를 만드는 방법은 필자의 방법으로 pdfView를 서브 문서로 지정하면 문서에 주석이 달아지지 않고/펜의 터치를 감지하지 못하기 때문에 – Codicil