本页内容
文本重排
使用以下方法将文本重新排列为适应设备屏幕尺寸,以显示适合在不同设备阅读的布局:
swift
let url = URL(fileURLWithPath:pdfPath)
if let document = CPDFDocument(url: url),
let page = document.page(at: 0) {
let range = NSRange(location: 0, length: Int(page.numberOfCharacters))
if let string = page.string(for: range) {
}
}
objective-c
NSURL *url = [NSURL fileURLWithPath:pdfPath];
CPDFDocument *document = [[CPDFDocument alloc] initWithURL:url];
CPDFPage *page = [document pageAtIndex:0];
NSRange range = NSMakeRange(0, page.numberOfCharacters);
NSString *string = [page stringForRange:range];