Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[native_pdf_view] Open a certain page when document is loaded #64

Open
MahmoudAshours opened this issue May 11, 2020 · 7 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@MahmoudAshours
Copy link

MahmoudAshours commented May 11, 2020

Describe the bug
I want to animate or jump to a certain page when document is loaded at the very start of rendering.

To Reproduce
1 - I tried to jump to a certain page when document is loaded in
onDocumentLoaded: (PdfDocument document) { _pdfController.jumpToPage(10); },

But I faced an exception :
Reloaded 9 of 868 libraries in 854ms. D/PDF_RENDER( 6672): OpenFileDocument. File: /data/user/0/projectname/cache/file_picker/Short-stories-from-100-Selected-Stories.pdf E/flutter ( 6672): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: type '_AssertionError' is not a subtype of type 'Exception' �[38;5;248mE/flutter ( 6672): #0 PdfController._loadDocument�[39;49m E/flutter ( 6672): <asynchronous suspension> �[38;5;248mE/flutter ( 6672): #1 PdfController._attach�[39;49m �[38;5;248mE/flutter ( 6672): #2 _PdfViewState.initState�[39;49m �[38;5;244mE/flutter ( 6672): #3 StatefulElement._firstBuild�[39;49m �[38;5;244mE/flutter ( 6672): #4 ComponentElement.mount�[39;49m �[38;5;244mE/flutter ( 6672): #5 Element.inflateWidget�[39;49m �[38;5;244mE/flutter ( 6672): #6 Element.updateChild�[39;49m �[38;5;244mE/flutter ( 6672): #7 SingleChildRenderObjectElement.mount�[39;49m �[38;5;244mE/flutter ( 6672): #8 Element.inflateWidget�[39;49m �[38;5;244mE/flutter ( 6672): #9 Element.updateChild�[39;49m �[38;5;244mE/flutter ( 6672): #10 ComponentElement.performRebuild�[39;49m �[38;5;244mE/flutter ( 6672): #11 Element.rebuild�[39;49m �[38;5;244mE/flutter ( 6672): #12 ComponentElement._firstBuild�[39;49m �[38;5;244mE/flutter ( 6672): #13 ComponentElement.mount�[39;49m �[38;5;244mE/flutter ( 6672): #14 Element.inflateWidget�[39;49m �[38;5;244mE/flutter ( 6672): #15 Element.updateChild�[39;49m �[38;5;244mE/flutter ( 6672): #16 ComponentElement.performRebuild�[39;49m �[38;5;244mE/flutter ( 6672): #17 Element.rebuild�[39;49m �[38;5;244mE/flutter ( 6672): #18 ComponentElement._firstBuild�[39;49m �[38;5;244mE/flutter ( 6672): #19 ComponentElement.mount�[39;49m �[38;5;244mE/flutter ( 6672): #20 Element.inflateWidget�[39;49m �[38;5;244mE/flutter ( 6672): #21 Element.updateChild�[39;49m �[38;5;244mE/flutter ( 6672): #22 ComponentElement.performRebuild�[39;49m �[38;5;244mE/flutter ( 6672): #23 Element.rebuild�[39;49m �[38;5;244mE/flutter ( 6672): #24 ComponentElement._firstBuild�[39;49m �[38;5;244mE/flutter ( 6672): #25 ComponentElement.mount�[39;49m �[38;5;244mE/flutter ( 6672): #26 Element.inflateWidget�[39;49m �[38;5;244mE/flutter ( 6672): #27 Element.updateChild�[39;49m �[38;5;244mE/flutter ( 6672): #28 ComponentElement.performRebuild�[39;49m �[38;5;244mE/flutter ( 6672): #29 Element.rebuild�[39;49m �[38;5;244mE/flutter ( 6672): #30 ComponentElement._firstBuild�[39;49m �[38;5;244mE/flutter ( 6672): #31 ComponentElement.mount�[39;49m �[38;5;244mE/flutter ( 6672): #32 Element.inflateWidget�[39;49m �[38;5;244mE/flutter ( 6672): #33 MultiChildRenderObjectElement.mount�[39;49m �[38;5;244mE/flutter ( 6672): #34 Element.inflateWidget�[39;49m �[38;5;244mE/flutter ( 6672): #35 Element.updateChild�[39;49m �[38;5;244mE/flutter ( 6672): #36 ComponentElement.performRebuild�[39;49m �[38;5;244mE/flutter ( 6672): #37 StatefulElement.performRebuild�[39;49m �[38;5;244mE/flutter ( 6672): #38 Element.rebuild�[39;49m �[38;5;244mE/flutter ( 6672): #39 ComponentElement._firstBuild�[39;49m �[38;5;244mE/flutter ( 6672): #40 StatefulElement._firstBuild�[39;49m �[38;5;244mE/flutter ( 6672): #41 ComponentElement.mount�[39;49m �[38;5;244mE/flutter ( 6672): #42 Element.inflateWidget�[39;49m �[38;5;244mE/flutter ( 6672): #43 Element.updateChild�[39;49m �[38;5;244mE/flutter ( 6672): #44 ComponentElement.performRebuild�[39;49m E/flutter ( 6672): #45 Element.rebuild (package:flutter/src/w

Expected behavior
I expected to open on the page I requested.

Screenshots

Screen Shot 2020-05-11 at 10 31 50 PM

Smartphone (please complete the following information):

  • Device: Android emulator Pixel 3a
  • OS: Android
  • Version : API 28
@MahmoudAshours MahmoudAshours added the bug Something isn't working label May 11, 2020
@SergeShkurko
Copy link
Member

and how many pages do you have in the document?
in 3.6.0 problem with errorBuilder fixed
can you copy the error code?

@copypasteearth
Copy link

Im having the same problem

@SergeShkurko SergeShkurko changed the title Open a certain page when document is loaded [native_pdf_view] Open a certain page when document is loaded Aug 9, 2020
@Jonathan-Harty
Copy link

I am running into the same problem with the animateToPage method, it seems that the scroll controller is not getting attached to the scroll view when any jumping around pages is done.
exception

@Jonathan-Harty
Copy link

It seems that the _positions list on the _pageController on the _pdfController does not get items until after the onDocumentLoaded function is called leading to the _positions.isNotEmpty assertion to fail.

@BrucesStuff
Copy link

According to the API, It seems to me that setting the initialPage parameter of the PdfController to >1 should cause the PDF to open at that page.

However this parameter seems to be ignored.

Looking into the code, I see that in the PdfController's _attach() method the initialPage is passed to _reInitPageController(), but not passed into _loadDocument(), which then calls _reInitPageController() again with an initialPage of 1 from its default parameter.

@Jonathan-Harty
Copy link

Jonathan-Harty commented Aug 18, 2020

I have already made a pull request that should fix the initialPage problem

@rahulserver
Copy link

Yes i too found the same issue like @BrucesStuff commented. The initialPage params seems to be ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants