使用PDFKIt iOS 11创建PDF注释

时间:2017-09-26 06:02:16

标签: swift annotations ios11 pdfkit

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

在apple提供的墨迹注释中,有一种方法可以将Bezier路径添加到注释中。

SELECT clientNumber,creationDate,customerNumber,checkedCustomer
      ,CLNT0001.TCM_CHECK_SUMMARY.COUNTRY_CODE countryCode
      ,CLNT0001.TCM_CHECK_SUMMARY.PST_KURZTEXT personStatus
      ,CLNT0001.TCM_CASE_COUNTRY_GROUP.COUNTRY_CODE homeCountryCode
      ,CLNT0001.TCM_CASE_COUNTRY_GROUP.PST_LFD_NR personStatusId
      ,CLNT0001.TCM_CASE_COUNTRY_GROUP.REGULATION regulation
      ,caseStatus,COC_SCORE_COUNT cocCaseCount ,CHECKED_CUSTOMER
 FROM   (
        SELECT   GEPRUEFT_JN checkedCustomer,INSTITUTSNR clientNumber ,KUNDNR customerNumber ,CASE_STATUS caseStatus,MAX(CREATION_DATE) creationDate,COUNT(DISTINCT b.KUNDNR) CHECKED_CUSTOMER 
        FROM     CLNT0001.TAXACTCASE 
        LEFT JOIN  CLNT0001.TCM_CHECK_SUMMARY b ON CLNT0001.TAXACTCASE.KUNDNR=b.KUNDNR
        WHERE    GEPRUEFT_JN = 'J' AND CREATION_DATE>='20170322000000000' AND 
                 CREATION_DATE<='20170323000000000'
        GROUP BY KUNDNR,INSTITUTSNR ,GEPRUEFT_JN,CASE_STATUS

        ) T1 INNER JOIN CLNT0001.TCM_CHECK_SUMMARY ON T1.customerNumber = CLNT0001.TCM_CHECK_SUMMARY.KUNDNR

 INNER JOIN CLNT0001.TCM_CASE_COUNTRY_GROUP ON T1.customerNumber = CLNT0001.TCM_CASE_COUNTRY_GROUP.KUNDNR
 WHERE T1.creationDate <= CLNT0001.TCM_CHECK_SUMMARY.HISTBIS
  AND T1.creationDate >= CLNT0001.TCM_CHECK_SUMMARY.HISTVON

即使添加了路径,也不会在PDF上绘制注释。 提前感谢所有宝贵的答案。

1 个答案:

答案 0 :(得分:2)

我不确定您是否对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)
}