简体   繁体   中英

How to extract bold text from pdf file programmatically using PDFKit in iOS?

I am using PDFKit to display my pdf files. I've integrated the searching functionality but I want to search only bold texts/words.

I'm wondering is it possible to do what I'm looking for or does Apple don't allow it? Because String data type is from Foundation class and UIFont is from UIKit.

I can search text only on the basis of lowercase, uppercase or text color. I've googled a lot. And I found that pdf files are made up of vectors. So, sometimes its difficult to extract the font-family of the text.

hm.. I guess you want to show all pdf files from your device's storage.

Generally.. if you want to show pdf file on your app, you should mapped the path and file name of the special folder into your code.

But I think you can't get the result you want with this method.

I am not sure In case this but probably you should use "UIDocumentPickerViewController".

I think also you need to set the value of documentTypes by [String(kUTTypePDF)] because you want to only show all the pdf.

Please check the following link for more details:

How to open the Document files eg(.pdf,.doc,.docx) in ios mobile when a button action using swift3.0?

The attributed string has the font attributes, using which you can achieve what you want. pdfDocument.page(at: 0)?.attributedString

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM