有什么方法可以找到當前的 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
}
}
}
有人可以向我解釋是否有可能,如果可以,請指導我如何實作這一點,我已經嘗試了很多搜索,但還沒有結果。
任何幫助將不勝感激。
提前致謝。
uj5u.com熱心網友回復:
我找到了檢查 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
}
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/435126.html
