Flutter Widget to display PDF

Overview

pdf_flutter

pub package

Inspired by Pdf_Viewer_Plugin ๐Ÿ˜‡ Wrapped around AndroidPdfViewer on Android. ๐Ÿ™๐Ÿผ

1. Add pdf_flutteron pubspec.yml

dependencies:
  pdf_flutter: ^version

2. On iOS enable PDF preview like this:

Add this on ios/Runner/info.plist:

    <key>io.flutter.embedded_views_preview</key>
    <true/>

3. Start Using

Load PDF from network (caches PDF from network)

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

Load PDF files

    File fileName;  
    PDF.file(
        fileName,
        height: 200,
        width: 100,
    )

Load PDF from assets

    PDF.assets(
        "assets/pdf/demo.pdf",
        height: 200,
        width: 100,
    )

For Production

Here are the steps to fix:
    1. Add proguard-rules.pro file if its not already there

    2. Inside of the proguard-rules.pro file put this:
        -keep class com.shockwave.**
        -keepclassmembers class com.shockwave.** { *; }
        
    3.In app/build.gradle add this:

        shrinkResources true
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

Demo

demo

Comments
  • App crashes

    App crashes

    I've only tried on android, and only using the pdf from network. In debug mode works properly but then when you build an apk, the app crashes instantly when is supposed to show the pdf. To reproduce the error you just have to create a new project and add the PDF. network widget provided by the package, then build an apk. For what I tried, this package is just what I need for my app and works great, except for this 'little' issue. I hope you can solve it.

    opened by valentinoguerra 18
  • Dependencies conflict

    Dependencies conflict

    Hi, I encountered a problem that says: pdf_flutter 1.1.4 depends on http ^0.12.2 and no versions of pdf_flutter match >1.1.4 <2.0.0, pdf_flutter ^1.1.4 requires http ^0.12.2 is it possible to update the http dependency to ^0.13.0? As it is conflicting with alot of other packages.

    opened by alanchan-dev 3
  • Implement a controller and listener in dart

    Implement a controller and listener in dart

    Request a feature to have a controller to jump to a page using dart code.

    Also a listener to report the current page number to let dart code react to it.

    Feature to hide the โ€1 of xxx" indicator for an easier internalisation, or provide a pattern/format/callback to display the string in different languages.

    enhancement 
    opened by bllaw 3
  • Suggestion: Mark package as discontinued on pub.dev

    Suggestion: Mark package as discontinued on pub.dev

    Hey @erluxman, I would recommend marking this package as discontinued at pub.dev because you don't maintain it for more than a year now.

    For example, this package is still not null safe on pub.dev and uses a deprecated version of the Android embedding.

    opened by devj3ns 2
  • How to set the height to fill the remaining space?

    How to set the height to fill the remaining space?

    I have a button on my app and I would like to the pdf viewer to fill the remaining space. Because I have another button widget, so I can't use double.infinity for the height. I tried to wrapped the PDF widget in Extended, but it does not make it to fill the remaining height.

    opened by zfc0812 2
  • Is there a way to force light mode?

    Is there a way to force light mode?

    Hi,

    Somehow, every time the PDF loads, if I have activated the dark mode on my iPhone, the background is black and I would like to make it always white. I already tried on my side forcing light mode but the PDF viewer still gets my phone's mode.

    Please, let me know if it's something from your side and how to solve it.

    I'm using version ^1.1.3.

    Thanks!

    opened by dcarriola 2
  • stuck in splash screen(white page) in android release build

    stuck in splash screen(white page) in android release build

    added proguard-rules.pro file, updated In app/build.gradle too. yfi in proguard file i was shown "Unresolved class name" for <com.shockwave.**>

    Please let me know if i'm missing something

    opened by krishnaaro 1
  • Upgrade dependencies and remove deprecations in the example app

    Upgrade dependencies and remove deprecations in the example app

    • I upgraded the dependencies and increased the version of this package to 1.1.5
    • I replaced the obsolete RaisedButton with ElevatedButton
    • I upgraded the file_picker dependency in the example app
    • I replaced some double quotes with single quotes
    opened by devj3ns 1
  • Is there a way to get the coordinates of a tap event on a page?

    Is there a way to get the coordinates of a tap event on a page?

    I would like to let the user add markers on the PDF. For that, I would need 2 things:

    1. Being able to listen to tap events on the PDF to get a set of coordinates X and Y
    2. Give the viewer a list of coordinates and some colors so that it can place the markers on top of the document

    I understand that it may not be supported at the moment but may I have some indications on how to start if I had to implement this? Thanks a lot!

    opened by GP4cK 1
  • Your link at

    Your link at " https://www.youtube.com/watch?v=xT654em3Lcs" i.e https://desiprogrammer.com/blogs/flutter-pdf is not opening

    I want to use your source code to upload pdf document from phone storage or url or assets mentioned in your youtube video.

    But I ma unable to access your page https://desiprogrammer.com/blogs/flutter-pdf.

    saying as

    This site canโ€™t be reached

    desiprogrammer.com unexpectedly closed the connection. Try:

    Checking the connection Checking the proxy and the firewall Running Windows Network Diagnostics ERR_CONNECTION_CLOSED

    opened by srk2k13 1
  • Blank Screen for some oppo phones for e.g oppo f15, oppo f11, oppo A9(mostly recently launched oppo phones), works on old oppo phones and other brands like samsung,nokia,realme,MI,leEco,vivo,LG,etc

    Blank Screen for some oppo phones for e.g oppo f15, oppo f11, oppo A9(mostly recently launched oppo phones), works on old oppo phones and other brands like samsung,nokia,realme,MI,leEco,vivo,LG,etc

    HELP! HELP! HELP!

    D/ColorViewRootUtil(19090): nav bar mode ignore false downX 436 downY 919 mScreenHeight 2340 mScreenWidth 1080 mStatusBarHeight 54 globalScale 1.3235294 nav mode 1 rotation 0 event MotionEvent { action=ACTION_DOWN, actionButton=0, id[0]=0, x[0]=436.0, y[0]=919.0, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=448244605, downTime=448244605, deviceId=2, source=0x1002, displayId=0 } I/flutter (19090): onTap Called I/flutter (19090): pdf url ------------------------ https://raw.githubusercontent.com/FlutterInThai/Dart-for-Flutter-Sheet-cheet/master/Dart-for-Flutter-Cheat-Sheet.pdf I/BufferQueue(19090): unnamed-19090-4 BufferQueue core=(19090:com.developer.example) W/eloper.example(19090): type=1400 audit(0.0:290148): avc: denied { read } for name="u:object_r:debug_bq_dump_prop:s0" dev="tmpfs" ino=2395 scontext=u:r:untrusted_app:s0:c60,c257,c512,c768 tcontext=u:object_r:debug_bq_dump_prop:s0 tclass=file permissive=0 E/libc (19090): Access denied finding property "vendor.debug.bq.dump" W/eloper.example(19090): type=1400 audit(0.0:290149): avc: denied { read } for name="u:object_r:debug_bq_dump_prop:s0" dev="tmpfs" ino=2395 scontext=u:r:untrusted_app:s0:c60,c257,c512,c768 tcontext=u:object_r:debug_bq_dump_prop:s0 tclass=file permissive=0 I/BufferQueueConsumer(19090): unnamed-19090-4 connect(C): consumer=(19090:com.developer.example) controlledByApp=true E/libc (19090): Access denied finding property "vendor.debug.bq.dump" I/BufferQueueConsumer(19090): unnamed-19090-4 setConsumerName: unnamed-19090-4 E/libc (19090): Access denied finding property "vendor.debug.bq.dump" I/BufferQueueConsumer(19090): SurfaceTexture-0-19090-4 setConsumerName: SurfaceTexture-0-19090-4 I/BufferQueueConsumer(19090): SurfaceTexture-0-19090-4 setDefaultBufferSize: width=1080 height=1942 D/com.shockwave.pdfium.PdfiumCore(19090): Starting PdfiumAndroid 1.9.0 I/BufferQueueProducer(19090): SurfaceTexture-0-19090-4 connect(P): api=1 producer=(659:???) producerControlledByApp=false D/ViewRootImplMainActivity: hardware acceleration = true , fakeHwAccelerated = false, sRendererDisabled = false, forceHwAccelerated = false, sSystemRendererDisabled = false D/BufferQueueProducer(19090): SurfaceTexture-0-19090-4 cancelBuffer: slot 0 I/InputTransport(19090): Create ARC handle: 0x776ec1fa80 I/flutter (19090): PDF view created D/BufferQueueProducer(19090): SurfaceTexture-0-19090-4 cancelBuffer: slot 0 D/Surface (19090): Surface::connect(this=0x776800f000,api=1) D/mali_winsys(19090): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000 D/Surface (19090): Surface::setBufferCount(this=0x776800f000,bufferCount=3) D/Surface (19090): Surface::allocateBuffers(this=0x776800f000) D/jniPdfium(19090): Init FPDF library D/BufferQueueProducer(19090): SurfaceTexture-0-19090-4 cancelBuffer: slot 0 D/BufferQueueProducer(19090): SurfaceTexture-0-19090-4 cancelBuffer: slot 0 D/BufferQueueProducer(19090): SurfaceTexture-0-19090-4 cancelBuffer: slot 0 D/BufferQueueProducer(19090): SurfaceTexture-0-19090-4 cancelBuffer: slot 0 D/BufferQueueProducer(19090): SurfaceTexture-0-19090-4 cancelBuffer: slot 0 D/BufferQueueProducer(19090): SurfaceTexture-0-19090-4 cancelBuffer: slot 0 D/BufferQueueProducer(19090): SurfaceTexture-0-19090-4 cancelBuffer: slot 0 D/BufferQueueProducer(19090): SurfaceTexture-0-19090-4 cancelBuffer: slot 0 D/BufferQueueProducer(19090): SurfaceTexture-0-19090-4 cancelBuffer: slot 0 D/BufferQueueProducer(19090): SurfaceTexture-0-19090-4 cancelBuffer: slot 0 D/BufferQueueProducer(19090): SurfaceTexture-0-19090-4 cancelBuffer: slot 0 D/BufferQueueProducer(19090): SurfaceTexture-0-19090-4 cancelBuffer: slot 0 D/BufferQueueProducer(19090): SurfaceTexture-0-19090-4 cancelBuffer: slot 0

    Screenshot of Black Screens:-

    1. https://drive.google.com/file/d/1ZQ9MjmVm74sjjJh2bAxkQ3kedcth13UA/view?usp=sharing
    2. https://drive.google.com/file/d/1z0Q5ilm6hOM94sDf9T-MrfvjSHjD0ItB/view?usp=sharing
    3. https://drive.google.com/file/d/1snTZQUxhB2yGhVb6lcYt5iIEYHM6CKNv/view?usp=sharing
    opened by karkhileshardul 1
  • Replace jcenter with mavenCentral

    Replace jcenter with mavenCentral

    Jcenter is deprecated since March 31st, 2021 and now its become unavailable: Build fails with issue:

    project :app > project :blah-blah

    Could not resolve blah-blah Could not get resource 'https://jitpack.io/blah-blah.pom'. Could not HEAD 'https://jitpack.io/blah-blah.pom'. Received status code 521 from server

    The Solution is to migrate the library to mavenCentral and replace it in the dependencies list.

    opened by akadatsky 0
  • Suggestion: Mark package as discontinued on pub.dev

    Suggestion: Mark package as discontinued on pub.dev

    Unfortunately, I have to reopen https://github.com/erluxman/pdf_flutter/issues/44 (from the beginning of the year) because nobody actively maintains this package.

    This package has still no null safety version on pub.dev and there are many open issues.

    Therefore, I would recommend marking this package as discontinued on pub.dev.

    opened by devj3ns 0
  • Flutter pdf_flutter issue

    Flutter pdf_flutter issue

    I am getting the following error when trying to build the apk file. Becuase of which it is not building. Please help as soon as possible.

    image

    Error :

    The plugin pdf_flutter uses a deprecated version of the Android embedding. To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs. If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.

    Please help me as soon as possible. Its urgent

    opened by chiragnahata 4
  • problem with git Actions

    problem with git Actions

    Execution failed for task ':app:checkDevReleaseAarMetadata'.

    Could not resolve all files for configuration ':app:devReleaseRuntimeClasspath'. Could not find com.github.barteksc:android-pdf-viewer:3.2.0-beta.1.

    Searched in the following locations: - https://dl.google.com/dl/android/maven2/com/github/barteksc/android-pdf-viewer/3.2.0-beta.1/android-pdf-viewer-3.2.0-beta.1.pom - https://repo.maven.apache.org/maven2/com/github/barteksc/android-pdf-viewer/3.2.0-beta.1/android-pdf-viewer-3.2.0-beta.1.pom - https://storage.googleapis.com/download.flutter.io/com/github/barteksc/android-pdf-viewer/3.2.0-beta.1/android-pdf-viewer-3.2.0-beta.1.pom - file:/home/runner/work/SafeUp/SafeUp/build/app/outputs/repo/com/github/barteksc/android-pdf-viewer/3.2.0-beta.1/android-pdf-viewer-3.2.0-beta.1.pom

     Required by:
         project :app > com.erluxman.pdf_flutter:pdf_flutter_release:1.0
    
    opened by piotritagsolutions 0
  • The plugin `pdf_flutter` uses a deprecated version of the Android embedding.

    The plugin `pdf_flutter` uses a deprecated version of the Android embedding.

    To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs. If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.

    opened by MobileMon 4
Releases(1.0)
Owner
Laxman Bhattarai
Android & Flutter Developer. Freelancer
Laxman Bhattarai
display a Dart string in Flutter using simple rich text characters

simple_rich_text Easily format Flutter text with simple format characters. Motivation: lowest-possible development friction to add color and formattin

Peter Alvin 16 Dec 5, 2022
A flutter package which contains a collection of Splash Screen example for your app to display logo and different text style.

splash_screen_view They say, first impression is the last! Yep, truly for any amazingly crafted application, it's easier to start impressing your audi

Sandip Kalola (SK) 17 Nov 25, 2022
๐Ÿ“ฑ๐ŸŒฆ Flutter application to display PWS (Personal Weather Station) data

PWSWatcher Why? PWSWatcher is an open-source Android app used to monitor a PWS (Personal Weather Station) given the link of its real-time updated .xml

Giorgio Bertolotti 17 Oct 13, 2022
The FlexGrid control provides a powerful and quickly way to display data in a tabular format. It is including that frozened column/row,loading more, high performance and better experience in TabBarView/PageView.

flex_grid Language: English| ไธญๆ–‡็ฎ€ไฝ“ The FlexGrid control provides a powerful and quickly way to display data in a tabular format. It is including that f

FlutterCandies 39 Nov 8, 2022
Compact representation of a placeholder for an image. Encode a blurry image under 30 caracters for instant display like used by Medium. Maintainer: @Solido

Flutter BlurHash Compact representation of a placeholder for an image. Generation You can use https://blurha.sh/ for testing or use any official api o

Flutter Community 408 Dec 30, 2022
LiveLine - A Health Monitoring/Awareness/Risk-Alert App which will display a Person's Heart rate, SpO2 level concentration and Body Temperature

A Health Monitoring/Awareness/Risk-Alert App which will display a Person's Heart rate, SpO2 (oxygen% in the body) level concentration and Body Temperature

Arpit Patawat 6 Jun 7, 2022
Learn Flutter on Flutter! A widget directory with implementation samples!

Fludget Browse through a variety of widgets used in flutter This application is developed to learn Flutter using Flutter. Different widgets used in fl

ACM VIT 29 Nov 23, 2022
QR.Flutter is a Flutter library for simple and fast QR code rendering via a Widget or custom painter.

QR.Flutter is a Flutter library for simple and fast QR code rendering via a Widget or custom painter. Need help? Please do not submit an issue for a "

Yakka 612 Jan 4, 2023
FileManager is a wonderful widget that allows you to manage files and folders, pick files and folders, and do a lot more. Designed to feel like part of the Flutter framework.

File Manager FileManager is a wonderful widget that allows you to manage files and folders, pick files and folders, and do a lot more. Designed to fee

Devs On Flutter 52 Dec 30, 2022
A Flutter widget to create an iOS settings-table (static TableView).

flutter_cupertino_settings A Flutter widget to create an iOS settings-table (static TableView). import 'package:flutter_cupertino_settings/flutter_cup

Matthias Rupp 234 Dec 28, 2022
Flutter - Blur Widgets - BackdropFilter Widget

blur_widgets Flutter - Blur Widgets - BackdropFilter Widget. Screenshot: Getting Started This project is a starting point for a Flutter application. A

Ulfhrafn 3 Dec 4, 2022
A credit card widget for Flutter application.

Flutter Credit Card A Flutter package allows you to easily implement the Credit card's UI easily with the Card detection. Preview Installing Add depen

Simform Solutions 285 Jan 8, 2023
A simple flutter widget to paint with your fingers

painter A simple flutter widget to paint with your fingers. Features The widget supports: Changing fore- and background color Changing the thickness o

EPNW 133 Dec 26, 2022
A Flutter widget that help you to create badages

badge A Flutter widget that help you to create badges easily. Getting Started Add dependency to pubspec.yaml [...] dependencies: badge: any [...] In

Raouf Rahiche 85 Jul 14, 2022
A flutter widget that show the camera stream and allow ML vision recognition on it, it allow you to detect barcodes, labels, text, faces...

Flutter Camera Ml Vision A Flutter package for iOS and Android to show a preview of the camera and detect things with Firebase ML Vision. Installation

Rushio Consulting 257 Jan 2, 2023
This is a basic flutter widget that shows the Buy me a coffee button.

Buy me a coffee widget Did you ever needed a widget for buy me a coffee, well here it is. Important note Be very careful with using this widget. Accor

Max Weber 8 May 12, 2022
Flutter video player widget based on video_player

Neeko Simple video player widget based on video_player. Neek supports more actions such as timeline control, toggle fullscreen and so on. Note: This p

OpenFlutter 70 Oct 20, 2022
Connectionstatusbar - Flutter connection status bar, widget that animates when internet connection changes

connection_status_bar A widget that animates when internet connection changes Getting Started add it to your dependencies then use it anywhere on your

Amir Ghezelbash 112 Nov 23, 2022
Video player-2.2.10 - A Flutter plugin for iOS, Android and Web for playing back video on a Widget surface

Video Player plugin for Flutter A Flutter plugin for iOS, Android and Web for pl

null 2 Sep 29, 2022