检查 PDF 内容大小并显示警报 Swift

Check PDF Content Size and show alert Swift

有什么方法可以找到当前的 pdf 内容大小。

例如:-

当用户打开 pdf 文件并在 pdf 中填写一些信息并单击提交按钮时。然后如何检查 pdf 内容大小意味着内容是否完全填充。如果用户没有完全添加详细信息,在 pdf 中等待一些 TextFiled,那么我们需要显示警告“请填写所有信息。”

代码:-

override func viewDidLoad() {
    super.viewDidLoad()
    if let documentURL = Bundle.main.url(forResource: pdfName, withExtension: "pdf") {
        if let document = PDFDocument(url: documentURL) {
            pdfView.autoScales = true
            pdfView.backgroundColor = UIColor.lightGray
            document.delegate = self
            pdfView.document = document
            pdfView.autoScales = true
        }
    }
}

有人可以向我解释一下吗 swift 如果可以,请指导我如何实现这一点,我已经尝试了很多搜索但还没有结果。

如有任何帮助,我们将不胜感激。

提前致谢。

我找到了检查 PDF 内容的解决方案。

代码:-

func checkPDFTextFiledDataBlankOrNot() {
    if let page = pdfVw.document?.page(at: 0){
        let annotations = page.annotations
        for annotation in annotations{
            if annotation.widgetStringValue == " "{
                annotation.widgetStringValue = "N/A"
                emptyTxtFields += 1
            }else {
                fillTxtfields  += 1
            }
        }
    }
}