Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

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

Open
Al-Krause-ex opened this issue May 2, 2022 · 27 comments

Comments

@Al-Krause-ex
Copy link

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

@Al-Krause-ex Al-Krause-ex changed the title The application crashes when I try to download a pdf file from assets (Android) The application crashes when I try to load a pdf file from assets (Android) May 2, 2022
@SureshKumar311
Copy link

for me too

1 similar comment
@brahimchebbi
Copy link

for me too

@roneicouto
Copy link

me too!

@mhabashy
Copy link

Me too

@Izudinalqasam
Copy link

me too, is there any fix ?

@PITPL-Maulik-Sinroja
Copy link

PITPL-Maulik-Sinroja commented May 30, 2022

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

@877209649
Copy link

me too

@amosesuwali
Copy link

Same Here

@Dakrain
Copy link

Dakrain commented Jun 3, 2022

Any update? I am getting the same issue too.

@chunsehun
Copy link

I have same issues...

@jhuhandha
Copy link

I have same issues with fromURL()

@xobe19
Copy link

xobe19 commented Jun 10, 2022

same issues!

1 similar comment
@neitcode
Copy link

same issues!

@anandsubbu007
Copy link

any update

@btraas
Copy link

btraas commented Jun 21, 2022

Same here

@kelvinwm
Copy link

Any update on this issue?.

@romankis95
Copy link

Same here

@ramonpaolo
Copy link

same problem here!

@yalda-student
Copy link

so am I

@ChurikiTenna
Copy link

same

@ghost
Copy link

ghost commented Jul 1, 2022

same here

@madhanKMani
Copy link

did any one find the solution for this issue?

@ramonpaolo
Copy link

I changed the lib pdf_viewer to pdf_render

@ysnky
Copy link

ysnky commented Jul 3, 2022

same issue

@vietstone-ng
Copy link

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

@anandyadav21219
Copy link

same issue

@frankperez87
Copy link

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

#117

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests