Hi all,
I am working with PDFKit's PDFAnnotation and I am using the text widget, everything is working fine, but I am super stuck on one thing. I noticed in the native PDFKit on my iPhone (Open a PDF on your phone, tap the icon on the top right, then tap the plus icon on the bottom right and select Text) It will add a text field to the PDF, when I tap on the text, the edit option appears, when I start editing the whole text is highlighted and then if I start typing, the text field gets bigger in width, if I goto a new line it get bigger in height. My question is how would I do that part? Make text field bigger in width or height pending on the text size as I keep typing?
let page = pdfView.currentPage textAnnotation = PDFAnnotation(bounds: CGRect(x: 550, y: 600, width: 600, height: 100), forType: PDFAnnotationSubtype(rawValue: PDFAnnotationSubtype.widget.rawValue), withProperties: nil) textAnnotation.widgetFieldType = PDFAnnotationWidgetSubtype(rawValue: PDFAnnotationWidgetSubtype.text.rawValue) textAnnotation.hasComb = true textAnnotation.font = UIFont.systemFont(ofSize: 80) textAnnotation.fontColor = .red textAnnotation.isMultiline = true textAnnotation.widgetStringValue = "Text Here" pdfView.addGestureRecognizer(textGestureRecognizer) textGestureRecognizer.textGestureRecognizerDelegate = self page!.addAnnotation(textAnnotation)
I really hope this makes sense as I have been struggling with this issue for days now. PLEASE HELP! How do I get the text widget to get bigger as I type? It just gets cut off becuase of the bounds I set for the Annotation