r/FlutterDev • • Jun 27 '20

Article I just open-sourced `pdf_flutter` a Widget to display PDF easily like Image.

I just released a plugin to display PDF in Flutter.

Now, it's super easy to load PDF from the network like it was loading images from the network.

I spent 2 days trying to display PDF easily in Flutter and I hope it will help other devs save some of their time.

  1. Add pdf_flutter on pubspec.yml

     dependencies:
       pdf_flutter: ^version
  2. On iOS enable PDF preview like by adding this on ios/Runner/info.plist:

     <key>io.flutter.embedded_views_preview</key>
     <true/>
  3. Start Using

     PDF.network(
         'https://raw.githubusercontent.com/FlutterInThai/Dart-for-Flutter-Sheet-cheet/master/Dart-for-Flutter-Cheat-Sheet.pdf',
         height: 500,
         width: 300,)

See demo and plugin here: pdf_flutter

154 Upvotes

21 comments sorted by

5

u/jahp21 Jun 27 '20

Nice work! Planning to do it for web?

1

u/erluxman Jun 27 '20

Not right now, but if you have any progress there, let's discuss this over a PR or issue?

1

u/[deleted] Jun 28 '20

Yes please could you make it compatible with Flutter Web?

1

u/erluxman Jun 28 '20

Can't promise right now but I have that in mind..

2

u/[deleted] Jun 28 '20

That would be awesome! Thank for your efforts!

0

u/[deleted] Jun 27 '20

[deleted]

1

u/erluxman Jun 27 '20

I couldn't think of this. I believe many won't either..

This is nothing special or tricky. Just a simple API who want to display PDF quick.

4

u/jahp21 Jun 27 '20

I guess it can all be in the same widget

2

u/[deleted] Jun 28 '20

Wait, you can do that in Flutter Web? How?

2

u/[deleted] Jun 28 '20

Nice! I always prefer easy ways to do things. Thanks for your library!

1

u/erluxman Jun 28 '20

Thanks :)

10

u/worldrobotdomination Jun 27 '20

Thanks for releasing this good work!

1

u/D_apps Jun 28 '20

Does it remember last viewed page?

1

u/erluxman Jun 28 '20

No not yet

1

u/costico123 Jun 28 '20

Just a random question , I have experience in c++ and java , but I don't know how do to get started with flutter , I am thinking of doing freecodecamps dart in 2hrs , can someone help me with how I should get started ?

2

u/ze_baco Jun 27 '20

Noice! Thx

0

u/[deleted] Jun 27 '20

[deleted]

9

u/erluxman Jun 27 '20

I will definitely do that.

I published this late at night so I had missed this aspect.

Thanks for the feedback..

1

u/erluxman Jun 28 '20

Updated it.. :) Can you have a look at it once & let me know if I can improve?

1

u/billylks Jun 28 '20
  1. Controller to let dart code to jump to a page number

  2. Hide the "1 of xxxx" indicator so that it is easier for internationalisation. Also a listener for dart code to display page number etc.

1

u/erluxman Jun 28 '20

Can you please file an issue about this? It will be preserved there well.

1

u/billylks Jun 28 '20

Done. Thank you.