readpdf 0.0.3 copy "readpdf: ^0.0.3" to clipboard
readpdf: ^0.0.3 copied to clipboard

PlatformAndroid

A plugin to read pdf files

example/lib/main.dart

import 'dart:io';

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:path_provider/path_provider.dart';
import 'package:readpdf/readpdf.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final _readpdfPlugin = Readpdf();

  Future<String> getAppDirectory() async{
    Directory appDocDir = await getApplicationDocumentsDirectory();
    return appDocDir.path;
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          //child: Text('Running on: $_platformVersion\n'),
          child:  MaterialButton(onPressed: (){
            //_readpdfPlugin.showAlert();
            _resultReadPdf();
          },
          color: Colors.green,
          child: const Text("View PDF")
          ),
        ),
      ),
    );
  }
  _resultReadPdf() async{
    String path = await getAppDirectory();
    debugPrint("value: $path/Beginning Flutter.pdf");
    String result;
    try {
      result = await _readpdfPlugin.viewPdf('$path/Beginning Flutter.pdf', 'Beginning Flutter', 'Grade 9', 'en', 4);
    }on PlatformException {
      result = 'Failed to get information.';
    }
    debugPrint("Result : $result");
  }
}
1
likes
140
points
35
downloads

Publisher

unverified uploader

Weekly Downloads

A plugin to read pdf files

Homepage

Documentation

API reference

License

BSD-3-Clause, MIT (license)

Dependencies

flutter, path_provider, plugin_platform_interface

More

Packages that depend on readpdf