【问题标题】:Exception has occurred. _Exception (Exception: Error reading PDF!) on loading pdf from url发生异常。 _Exception(异常:读取 PDF 时出错!)从 url 加载 pdf
【发布时间】:2020-08-12 18:09:44
【问题描述】:

我正面临这些错误

  • 发生异常。 _Exception(异常:读取 PDF 时出错!)从 url 加载 pdf 时
  • 在加载 pdf 表单资产时无法解析资产

这是我的代码


  loadfile() async {
    document = await PDFDocument.fromURL(
        'http://www.africau.edu/images/default/sample.pdf');

    setState(() {
      document = document;
    });
  }
      body: Center(child: PDFViewer(document: document)),

【问题讨论】:

    标签: flutter flutter-dependencies


    【解决方案1】:
    import 'package:url_launcher/url_launcher.dart';
    
    _launchURL() async {
     const url = 'https://flutter.dev/exapmle.pdf';
    if (await canLaunch(url)) {
    await launch(url);
     } else {
    throw 'Could not launch $url';
     }
    }
    

    你可以在不下载文件的情况下使用它,使用包从 URL 打开:url_launcher

    【讨论】:

    • 我正在使用flutter_plugin_pdf_viewer
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-27
    • 1970-01-01
    • 2015-11-25
    • 2010-11-01
    • 1970-01-01
    • 2018-04-01
    • 1970-01-01
    相关资源
    最近更新 更多