gpt4 book ai didi

ios - CoreGraphics PDF 记录了一个错误。设置环境变量 "CG_PDF_VERBOSE"以了解更多信息

转载 作者:IT王子 更新时间:2023-10-29 06:58:06 26 4
gpt4 key购买 nike

我正在尝试将 iOS PDFKit 嵌入到我的 Flutter 应用程序中。以下是我的代码

public class PDFCustomView: NSObject, FlutterPlatformView {

let frame: CGRect
let viewId: Int64

init(_ frame: CGRect,viewId: Int64, args: Any?){
self.frame = frame
self.viewId = viewId
}

public func view() -> UIView {
let pdfView = PDFView(frame: frame)
if let path = Bundle.main.path(forResource: "studenthandbook2018", ofType: "pdf") {
let url = URL(fileURLWithPath: path)
if let pdfDocument = PDFDocument(url: url) {
pdfView.displayMode = .singlePageContinuous
pdfView.autoScales = true
pdfView.document = pdfDocument
}
}
return PDFView()
}

}

public class PdfViewFactory: NSObject, FlutterPlatformViewFactory {
public func create(withFrame frame: CGRect, viewIdentifier viewId: Int64, arguments args: Any?)
-> FlutterPlatformView {
return PDFCustomView(frame,viewId: viewId,args: args)
}
}

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)

let viewFactory = PdfViewFactory()
registrar(forPlugin: "iospdf").register(viewFactory, withId: "PDFIOSView")

return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}

我还包括了

<key>io.flutter.embedded_views_preview</key>
<true/>

info.plist

我没有返回 PDFView,而是尝试返回 UISLider,它在我的应用程序中正常工作,但 PDFkit 给出错误提示 CoreGraphics PDF 已记录错误。设置环境变量“CG_PDF_VERBOSE”以了解更多信息。

这是 Flutter 错误还是我做错了什么?

最佳答案

第 1 步:如图所示编辑方案 enter image description here

第 2 步:添加一个新的环境变量,如下所示: enter image description here

第 3 步:查看 XCode 日志中显示的错误。就我而言,它正在打印

missing or invalid CIDToGIDMap entry.

快速搜索表明我正在使用的 pdf 文件可能缺少一些嵌入的字体。

关于ios - CoreGraphics PDF 记录了一个错误。设置环境变量 "CG_PDF_VERBOSE"以了解更多信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54971163/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com