我有一个应用程序可以拍摄文档照片,然后在新的 UIViewController 的 PDFView 中显示为 pdf。我遇到的问题是,当显示 pdf 文档时,它是一些放大的内容,默认情况下 PDFView 不显示文档的完整轮廓。我该如何实现?
class ShowPDFViewController: UIViewController{
@IBOutlet weak var pdfPreview: PDFView!
var pdfDocument: PDFDocument!
override func viewDidLoad() {
super.viewDidLoad()
// PRESENT PDF DOCUMENT JUST CREATED
pdfPreview.document = pdfDocument
pdfPreview.autoScales = true
}
}
这是 pdf 文档当前默认显示的方式 - 通常是缩放的:
这就是我希望文档默认呈现的方式 - 文档的完整大纲请参阅:
最佳答案
我通过以下方式从代码创建 View 并且它工作(左侧和右侧与 super View 左右对齐,高度缩放以适合)
var pdfView = PDFView(frame: view.frame)
pdfView.document = PDFDocument(url: Bundle.main.url(forResource: "doc"
, withExtension: "pdf")!)
pdfView.displayMode = .singlePage
pdfView.autoScales = true
view.addSubview(pdfView)
关于ios - 如何在PDFView中呈现单页pdf文档,使文档居中完整呈现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52441427/