CrossPT / flutter_plugin_pdf_viewer

A flutter plugin for handling PDF files. Works on both Android & iOS
BSD 3-Clause "New" or "Revised" License
92 stars 309 forks source link

Exception has occurred. _Exception (Exception: Error reading PDF!) #81

Open 7Eltantawy opened 3 years ago

7Eltantawy commented 3 years ago

Exception has occurred. _Exception (Exception: Error reading PDF!)

I'm facing this error on loading pdf from url This is myCode

import 'package:flutter/material.dart';
import 'package:flutter_plugin_pdf_viewer/flutter_plugin_pdf_viewer.dart';

class PdfViwer extends StatefulWidget {
  PdfViwer(this.urlPath);
  final urlPath;

  @override
  _PdfViwerState createState() => _PdfViwerState();
}

class _PdfViwerState extends State<PdfViwer> {
  bool nighmode = false;
  bool pageSnapping = false;
  bool isloading = false;

  PDFDocument document;

  @override
  void initState() {
    super.initState();

    loadfile();
  }

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

    setState(() {
      document = document;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title: Text('PDF'),
      ),
      body: Center(child: PDFViewer(document: document)),
    );
  }
}
Ahmedhassan50 commented 3 years ago

did you find solve ?

7Eltantawy commented 3 years ago

No, I used URL launcher instead but I hope to find a solution