scientifichackers / flutter_pdf_viewer

A native PDF viewer for flutter.
MIT License
107 stars 40 forks source link

Support Inline Pdf Viewing #1

Open MaskyS opened 6 years ago

MaskyS commented 6 years ago

Thank you a lot for this plugin. It's amazing, the one thing it lacks is to add an AppBar in the pdfViewer activity. Any idea how it could be done? Maybe like the flutter webview plugin does?

Thanks again!

devxpy commented 6 years ago

I can get you a Android native appBar, but that's pretty useless since its just a top bar with the name of the app.

In Android, we have the back button so going back to the app is not an issue?

To get any sort of flutter component onto that PDF screen requires some sort of compositing engine that combines both flutter and Android views into one.

I'll look more into how webview plugin does it, with it's rect analogy, whether that applies to Android PDF viewer...

devxpy commented 6 years ago

Update-

The webview plugin uses a FrameLayout, which works fine. But IMO, provides a mediocre experience. It feels like a weird mix of android and flutter views to me...

I personally, would like to try out flutter Texture. I believe that it should look and feel like a non-GMO flutter widget.

For instance, it's used by fluttie.

The library can render the animations by piping the output from the Lottie Android library into a Flutter texture.

MaskyS commented 6 years ago

Great, thanks for the prompt reply. I look forward to this :D

allanwolski commented 6 years ago

I look forward to this too :D

devxpy commented 6 years ago

Been quite busy with zproc.

This is definitely on my to-do list.

ghost commented 6 years ago

Zproc looks cool. Using IPC. You should also consider NATS. I get 800 k transactions a second on my old MacBook. Has drivers in python and very easy to use. It's a well known compeditoor to zmq. I use it with flutter as well as for servers

On Sun, 26 Aug 2018, 00:41 Dev Aggarwal, notifications@github.com wrote:

Been busy with zproc https://github.com/pycampers/zproc.

This is definitely on my to-do list.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pycampers/flutter_pdf_viewer/issues/1#issuecomment-416001131, or mute the thread https://github.com/notifications/unsubscribe-auth/ATuCwsJT6JKcxw5UzcdgcdJVJS7bRIejks5uUdK2gaJpZM4VlYpL .

ghost commented 6 years ago

Great research here. Flutter Textures is an interesting approach. But it will mean you will loose any clipboard ability maybe ? No sure. But yes I was using the Textures approach to render 3d models and spin them. Not fast of course.

On Mon, 30 Jul 2018, 07:27 Dev Aggarwal, notifications@github.com wrote:

Update-

The webview plugin uses a FrameLayout https://developer.android.com/reference/android/widget/FrameLayout, which works fine. But IMO, provides a mediocre experience. It feels like a weird mix of android and flutter views to me...

I personally, would like to try out flutter Textures https://docs.flutter.io/flutter/widgets/Texture-class.html. Since they are flutter widgets, I hope that they look and feel like a non-GMO flutter app ;)

For instance, it's used by fluttie https://pub.dartlang.org/packages/fluttie.

The library can render the animations by piping the output from the Lottie Android library into a Flutter texture.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pycampers/flutter_pdf_viewer/issues/1#issuecomment-408750745, or mute the thread https://github.com/notifications/unsubscribe-auth/ATuCwsBdL7R0nuhs6PY_PgYnvIViEof8ks5uLpkqgaJpZM4VlYpL .

devxpy commented 6 years ago

Thanks, will check it out.

zproc is also compatible with TCP btw.

I'm trying to get a stable feature-set first. (Working on a PUSH-PULL model right now)

But if NATS really is faster than ZMQ, I wouldn't mind putting it as an alternative backend.

ghost commented 6 years ago

Checkout liftbridge. It's NATS exposed over grpc. Replaces Kafka. I can then use this high transaction MQ to talk to flutter over grpc. Grpc Dart with grpc golang - easy.

Also because it's like Kafka you get distributed logs. You also get multi data centre multi master for free.

When you add another node it joins and load balancers. Nothing else needed.

Liftbridge is just one of the many systems you can build on top of NATS.

devxpy commented 6 years ago

Not fast of course.

What exactly was the bottleneck, the 3d rendering library or the Textures API?

ghost commented 6 years ago

Pumping the textures to the flutter texture object is not fast. The fluttie team use it and when you try it it's not that fast. But I would still go with it to just get going.

I saw another flutter project also using the Texture Flutter object. It was a 3d model viewer. Slow but worked. They were designed to use opengl I think. Can't find the link now.

Anyway I think getting a MVP going is first Step

allanwolski commented 6 years ago

Would it be possible to use the new AndroidView created for Inline Google Maps?

https://github.com/flutter/flutter/issues/19030#issuecomment-416393456 https://github.com/flutter/plugins/pull/743#pullrequestreview-150361671

ghost commented 6 years ago

@allanwolski thats looks very interesting !

I think it worth trying and then comparing what it gives with the Flutter Texture approach.

One thing i noticed between the two approaches is he z buffer. With Android Views it seems to be top always. With Flutter Texture you have control of the z buffer. I have not tried it but only read it.

SO when you open the drawer you might get bad UX experience with android view. But gotta try it, and its very new

allanwolski commented 6 years ago

I also think it's worth a try.

This may help: https://medium.com/flutter-community/flutter-platformview-how-to-create-flutter-widgets-from-native-views-366e378115b6 https://docs.flutter.io/flutter/widgets/AndroidView-class.html

ghost commented 6 years ago

So this is basically rastisinh it to an image ?

There are tons of libs that do that but I presume you want it written in dart ?

On Sat, 8 Sep 2018, 18:36 allanwolski, notifications@github.com wrote:

I also think it's worth a try.

This may help:

https://medium.com/flutter-community/flutter-platformview-how-to-create-flutter-widgets-from-native-views-366e378115b6 https://docs.flutter.io/flutter/widgets/AndroidView-class.html

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/pycampers/flutter_pdf_viewer/issues/1#issuecomment-419656095, or mute the thread https://github.com/notifications/unsubscribe-auth/ATuCwmZYRfrB435lytGqq0SUs5AqGnqcks5uY_ITgaJpZM4VlYpL .

allanwolski commented 6 years ago

Yes, I want written in dart.

This is the layout I need port to Flutter:

e4b37cb9-c35a-4911-9cbd-0a3089b367c4

devxpy commented 6 years ago

Quick Status update - will look into this issue after iOS support is enabled.

allanwolski commented 6 years ago

Any progress on this?

devxpy commented 6 years ago

@allanwolski

I have a MVP working at the inline branch.

(example)

Screenshot

However, it seems that there are still some rough edges; Here are some I encountered.

Once these are ironed out, I will merge into master.

Current implementation uses flutter's new AndroidView, which is considered a beta feature as of now. It is possible that bugs are inherited from upstream.

I might not be closing the PDFView on the Java side properly. Anyone with more experience here?

allanwolski commented 6 years ago

Great job, @devxpy!

I tested here and found only the problems reported by you. The performance is very good!

dariotrombello commented 6 years ago

I experience crashes with multiple tabs and the plugin of the inline branch. Maybe i can send logs later.

dariotrombello commented 6 years ago

But anyways thank you very much for this :+1:

devxpy commented 6 years ago

@Borduni multiple tabs, can you please provide more context?

dariotrombello commented 6 years ago

I have a layout with a bottom navigation bar (3 pages). The app crashes when switching between them after implementing this plugin. If I revert it everything is fine again

MaskyS commented 6 years ago

@Borduni I think it would really help if you could provide some error logs :smile_cat:

dariotrombello commented 5 years ago

Okay I think the error was because of my phone. I have installed a custom rom. Tried it on the same phone without any modifications and it worked, thanks!

devxpy commented 5 years ago

That's weird. This could be an issue upstream with flutter. Let me try upgrading to flutter 1.0

allanwolski commented 5 years ago

@devxpy

Do you have any idea when this will merge into master? Also wanted to know if you have plans for iOS?

devxpy commented 5 years ago

@allanwolski I cannot say for sure when this will merge into master. I still have these issues, with really no idea why they're happening. The flutter Platform views are still a preview feature.

I really want to do ios, but cannot seem to get my hands on a compiler :/

MaskyS commented 5 years ago

@devxpy, any updates on this? Do the bugs still occur?

Xaeroxaero commented 5 years ago

I found i out that if you add to AndroidManifest.xml `

` and create Activity Listener

class PdfActivity : Activity() {} and include it in PdfViewerThread class PdfViewerThread( val instance: FlutterPdfViewerPlugin, val methodCall: MethodCall, val result: MethodChannel.Result, val activity: PdfActivity = PdfActivity() ) : Thread()

the view will rerender after changing orientation. But some stack trace error occurs during that

marianoarga commented 4 years ago

@Xaeroxaero where is PdfViewerThread?