1

我正在尝试在 PDF 中快速构建目录。尽管显示了边界和背景颜色,但我的按钮没有显示任何文本。

let anno: PDFAnnotation  = PDFAnnotation(bounds: CGRect(x: xPosition, y: yPosition, width: 300, height: 40), forType: .widget, withProperties: nil)

anno.widgetFieldType = .button
anno.backgroundColor = UIColor.white
anno.fontColor = UIColor.black
anno.alignment = NSTextAlignment.center
anno.destination = PDFDestination()
anno.fieldName = "Button Third try"
anno.widgetStringValue = "button hello?"
anno.caption = "This is a test button"
            
anno.draw(with: PDFDisplayBox.mediaBox, in: context.cgContext)

最终我想点击一个链接到我的 Pdf 文档中的一个页面

4

1 回答 1

1

您需要设置widgetControlType.pushButtonControl

anno.widgetControlType = .pushButtonControl

Apple 示例代码演示了将小部件添加到 PDF 中,值得一试。

于 2021-07-08T21:14:27.163 回答