GithubHelp home page GithubHelp logo

chaudharydeepanshu / pdf_bitmaps Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 102 KB

A flutter PDF pages images generator which also helps with few other common pdf related things.

Home Page: https://pub.dev/packages/pdf_bitmaps

License: BSD 3-Clause "New" or "Revised" License

Kotlin 53.00% Dart 47.00%
flutter pdf-renderer dart kotlin pdf-bitmaps pdf-page-count android flutter-plugin pdf plugin

pdf_bitmaps's Introduction

pub package wakatime

Word from creator

HelloπŸ‘‹, This package is completely compatible with flutter and it also supports using Android Uri of picked file to work with which offer some real benefits such as getting pdf any page bitmap without first caching that pdf or validating them without caching.

Yes, without a doubt, giving a free πŸ‘ or ⭐ will encourage me to keep working on this plugin.

Package description

A flutter PDF pages images generator which also helps with few other common pdf related things.

Features

  • Works on Android 5.0 (API level 21) or later.
  • Generate images of pdf pages using absolute file path or Android native Uri.
  • Ability to generate images of pdf pages with different background color, scale (size/quality), and rotation angle.
  • Check if PDF is valid or not.
  • Check if PDF is protected or not.
  • Get PDF total number of pages count.
  • Get any PDF page width and height.

Note: If you are getting errors in you IDE after updating this plugin to newer version and the error contains works like Redeclaration, Conflicting declarations, Overload resolution ambiguity then to fix that you probably need to remove the older version of plugin from pub cache C:\Users\username\AppData\Local\Pub\Cache\hosted\pub.dev\older_version or simply run flutter clean.

Getting started

  • In pubspec.yaml, add this dependency:
pdf_bitmaps: 
  • Add this package to your project:
import 'package:pdf_bitmaps/pdf_bitmaps.dart';

Basic Usage

Getting the PDF total page count

int? pageCount = await PdfBitmaps().pdfPageCount(
  params: PDFPageCountParams(pdfPath: pdfPath),
);

Getting a PDF page image data

String? imageCachedPath = await PdfBitmaps().pdfBitmap(
  params: PDFBitmapParams(
    pdfPath: pdfPath,
    pageInfo: BitmapConfigForPage(
        pageNumber: 1,
        rotationAngle: 90,
        scale: 0.5,
        backgroundColor: Colors.red,
    ),
    pdfRendererType: PdfRendererType.androidPdfRenderer,
  ),
);

Uint8List? bytes = File(imageCachedPath!).readAsBytesSync();

Note:

  • scale should be greater than 0 and less than or equal to 5. By default it is 1.
  • backgroundColor is Colors.white by default.
  • rotationAngle is 0 by default.
  • pdfRendererType is PdfRendererType.androidPdfRenderer by default as its fast but PdfRendererType.pdfBoxPdfRenderer is recommended for PDF with very high resolution images as PdfRendererType.androidPdfRenderer may create a white useless image.

Getting the PDF validity and protection info

PdfValidityAndProtection? pdfValidityAndProtectionInfo = await PdfBitmaps().pdfValidityAndProtection(
  params: PDFValidityAndProtectionParams(pdfPath: pdfPath),
);

bool? isPDFValid = pdfValidityAndProtectionInfo?.isPDFValid;
bool? isPDFProtected = pdfValidityAndProtectionInfo?.isOpenPasswordProtected;

Note:

  • A PDF would still be valid even if it is protected.
  • A PDF is protected if the PDF has an open/user password set.

Getting a PDF page size info

PageSizeInfo? pageSizeInfo = await PdfBitmaps().pdfPageSize(
  params: PDFPageSizeParams(pdfPath: pdfPath, pageNumber: pageNumber),
);

int? widthOfPage = pageSizeInfo?.widthOfPage;
int? heightOfPage = pageSizeInfo?.heightOfPage;

Note: To try the demos shown in below gifs run the example included in this plugin.

Loading PDF pages in Gridview PDF validity and protection info PDF page size info

pdf_bitmaps's People

Contributors

chaudharydeepanshu avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.