flutter_pdf_printer 1.1.0+1 copy "flutter_pdf_printer: ^1.1.0+1" to clipboard
flutter_pdf_printer: ^1.1.0+1 copied to clipboard

A simple PDF printer for Android and iOS.Currently only works with PDFs.

example/lib/main.dart

import 'dart:io';

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:http/http.dart' as http;
import 'package:flutter_pdf_printer/flutter_pdf_printer.dart';
import 'package:path_provider/path_provider.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  Future<File> _downloadFile(String url, String filename) async {
    http.Client _client = new http.Client();
    var req = await _client.get(Uri.parse(url));
    var bytes = req.bodyBytes;
    String dir = (await getApplicationDocumentsDirectory()).path;
    File file = new File('$dir/$filename');
    await file.writeAsBytes(bytes);
    return file;
  }

  /// Prints a sample pdf printer
  void printPdfFile() async {
    var file = await _downloadFile(
        "http://www.africau.edu/images/default/sample.pdf", "test.pdf");
    await FlutterPdfPrinter.printFile(file.path);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: RaisedButton(
            child: Text("Download and print pdf!"),
            onPressed: printPdfFile,
          ),
        ),
      ),
    );
  }
}
6
likes
30
pub points
51%
popularity

Publisher

unverified uploader

A simple PDF printer for Android and iOS.Currently only works with PDFs.

Repository (GitHub)
View/report issues

License

Apache-2.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_pdf_printer