lohanidamodar / pdf_viewer

A flutter plugin for handling PDF files. Works on both Android & iOS
https://pub.dev/packages/advance_pdf_viewer
BSD 3-Clause "New" or "Revised" License
61 stars 143 forks source link

The application crashes when I try to load a pdf file from assets (Android) #110

Open Al-Krause-ex opened 2 years ago

Al-Krause-ex commented 2 years ago

When I load a pdf file from assets, my application crashes. The PDF file is 2 MB.

The code: import 'package:advance_pdf_viewer/advance_pdf_viewer.dart'; import 'package:flutter/material.dart';

class PdfPage extends StatefulWidget { const PdfPage({Key? key}) : super(key: key);

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

class _PdfPageState extends State<PdfPage> { PDFDocument? doc; var isLoading = false;

@override void initState() { isLoading = true; loadDoc(); super.initState(); }

Future loadDoc() async { doc = await PDFDocument.fromAsset('assets/pdfs/screen.pdf'); setState(() { isLoading = false; }); } @override Widget build(BuildContext context) { return Scaffold( body: Center( child: isLoading ? const CircularProgressIndicator() : PDFViewer(document: doc!), )); } }

Mistake:

I/System.out(17782): Already closed W/System.err(17782): java.lang.IllegalStateException: Already closed W/System.err(17782): at android.graphics.pdf.PdfRenderer.throwIfClosed(PdfRenderer.java:270) W/System.err(17782): at android.graphics.pdf.PdfRenderer.close(PdfRenderer.java:187) W/System.err(17782): at pt.tribeiro.flutter_plugin_pdf_viewer.FlutterPluginPdfViewerPlugin.getPage(FlutterPluginPdfViewerPlugin.java:206) W/System.err(17782): at pt.tribeiro.flutter_plugin_pdf_viewer.FlutterPluginPdfViewerPlugin.access$100(FlutterPluginPdfViewerPlugin.java:31) W/System.err(17782): at pt.tribeiro.flutter_plugin_pdf_viewer.FlutterPluginPdfViewerPlugin$1.run(FlutterPluginPdfViewerPlugin.java:84) W/System.err(17782): at android.os.Handler.handleCallback(Handler.java:888) W/System.err(17782): at android.os.Handler.dispatchMessage(Handler.java:100) W/System.err(17782): at android.os.Looper.loop(Looper.java:213) W/System.err(17782): at android.os.HandlerThread.run(HandlerThread.java:67) D/PdfViewerPlugin(17782): Retrieving page failed. D/AndroidRuntime(17782): Shutting down VM I/QarthLog(17782): [PatchStore] createDisableExceptionQarthFile I/QarthLog(17782): [PatchStore] create disable file for com.example.pdf_check uid is 10661 E/AndroidRuntime(17782): FATAL EXCEPTION: main E/AndroidRuntime(17782): Process: com.example.pdf_check, PID: 17782 E/AndroidRuntime(17782): java.lang.IllegalStateException: Reply already submitted E/AndroidRuntime(17782): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:431) E/AndroidRuntime(17782): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:264) E/AndroidRuntime(17782): at pt.tribeiro.flutter_plugin_pdf_viewer.FlutterPluginPdfViewerPlugin$1$2.run(FlutterPluginPdfViewerPlugin.java:92) E/AndroidRuntime(17782): at android.os.Handler.handleCallback(Handler.java:888) E/AndroidRuntime(17782): at android.os.Handler.dispatchMessage(Handler.java:100) E/AndroidRuntime(17782): at android.os.Looper.loop(Looper.java:213) E/AndroidRuntime(17782): at android.app.ActivityThread.main(ActivityThread.java:8178) E/AndroidRuntime(17782): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(17782): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) E/AndroidRuntime(17782): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101) E/flutter (17782): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method getPage on channel flutter_plugin_pdf_viewer) E/flutter (17782): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:175:7) E/flutter (17782): E/flutter (17782): #1 PDFDocument.get (package:advance_pdf_viewer/src/document.dart:97:18) E/flutter (17782): E/flutter (17782): #2 _PDFViewerState._loadPage (package:advance_pdf_viewer/src/viewer.dart:151:18) E/flutter (17782): E/flutter (17782): I/Process (17782): Sending signal. PID: 17782 SIG: 9

SureshKumar311 commented 2 years ago

for me too

brahimchebbi commented 2 years ago

for me too

roneicouto commented 2 years ago

me too!

mhabashy commented 2 years ago

Me too

Izudinalqasam commented 2 years ago

me too, is there any fix ?

PITPL-Maulik-Sinroja commented 2 years ago

I am using this PDFDocument.fromURL(documentURL) and getting the same issue with my Android device. iOS device works well.

877209649 commented 2 years ago

me too

amosesuwali commented 2 years ago

Same Here

Dakrain commented 2 years ago

Any update? I am getting the same issue too.

chunsehun commented 2 years ago

I have same issues...

jhuhandha commented 2 years ago

I have same issues with fromURL()

xobe19 commented 2 years ago

same issues!

neitcode commented 2 years ago

same issues!

anandsubbu007 commented 2 years ago

any update

btraas commented 2 years ago

Same here

kelvinwm commented 2 years ago

Any update on this issue?.

romankis95 commented 2 years ago

Same here

ramonpaolo commented 2 years ago

same problem here!

yalda-student commented 2 years ago

so am I

ChurikiTenna commented 2 years ago

same

ghost commented 2 years ago

same here

madhanKMani commented 2 years ago

did any one find the solution for this issue?

ramonpaolo commented 2 years ago

I changed the lib pdf_viewer to pdf_render

ysnky commented 2 years ago

same issue

vietstone-ng commented 1 year ago

I use the previous version (2.0.0) as this Stackoverflow answer, then it work https://stackoverflow.com/a/71226926/566360

anandyadav21219 commented 1 year ago

same issue

frankperez87 commented 1 year ago

Seems like Version 2.0.2 solved the issue for me. I posted what I did here.

https://github.com/lohanidamodar/pdf_viewer/issues/117